-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
060319 - poly version 5 - build done
- Loading branch information
1 parent
6da7c56
commit df89e00
Showing
14 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "Circle.h" | ||
Circle::Circle(float r): Ellipse(r, r) {} | ||
|
||
void Circle::Input(istream& inDev) | ||
{ | ||
inDev >> Ra; | ||
Rb = Ra; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef _CIRCLE_ | ||
#define _CIRCLE_ | ||
#include "Ellipse.h" | ||
class Circle: public Ellipse | ||
{ | ||
public: | ||
Circle(float r = 0); | ||
virtual void Input(istream& inDev); | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "Ellipse.h" | ||
Ellipse::Ellipse(float a, float b) | ||
{ | ||
Ra = a; Rb = b; | ||
} | ||
void Ellipse::Input(istream& inDev) | ||
{ | ||
inDev >> Ra >> Rb; | ||
} | ||
float Ellipse::Area() | ||
{ | ||
return PI * Ra * Rb; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef _ELLIPSE_H | ||
#define _ELLIPSE_H | ||
#define PI (float)3.14159 | ||
#include "Figure.h" | ||
|
||
class Ellipse : public Figure | ||
{ | ||
protected: | ||
float Ra, Rb; | ||
public: | ||
Ellipse(float a = 0, float b = 0); | ||
virtual void Input(istream& inDev); | ||
virtual float Area(); | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef _Figure_h | ||
#define _Figure_h | ||
#include <iostream> | ||
using namespace std; | ||
|
||
class Figure | ||
{ | ||
public: | ||
virtual void Input(istream& inDev) = 0; | ||
virtual float Area() = 0; | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "Figure.h" | ||
#include "Square.h" | ||
#include "Circle.h" | ||
#include "Triangle.h" | ||
|
||
Figure* figMaxArea(Figure* figs[], int nFig) | ||
{ | ||
Figure* figMax = NULL; | ||
cout << endl << "figMaxArea: " << figs[0]->Area(); | ||
if (nFig > 0) | ||
{ | ||
figMax = figs[0]; | ||
for (int i = 1; i < nFig; i++) | ||
{ | ||
cout << " " << figs[i]->Area(); | ||
if (figMax->Area() < figs[i]->Area()) | ||
{ | ||
figMax = figs[i]; | ||
} | ||
} | ||
} | ||
return figMax; | ||
} | ||
int main() | ||
{ | ||
cout << endl << "polyV5RectangleSquare MainProgRecSqua.cpp Triangle.cpp Circle.cpp Ellipse.cpp Square.cpp Rectangle.cpp" << endl; | ||
|
||
Figure* Figs[] = { new Rectangle(9.3F, 9.7F), new Circle(4.5F), | ||
new Ellipse(9.24, 4.7F), new Square(9.5F), | ||
new Triangle(10.7F, 6.4F), new Ellipse(3.7F, 7.8F) | ||
}; | ||
int nFig = sizeof(Figs)/sizeof(Figure*); | ||
Figure* aFig = figMaxArea(Figs, nFig); | ||
if (aFig != NULL) | ||
{ | ||
cout << endl << "Max = " << aFig->Area() << endl; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "Rectangle.h" | ||
|
||
Rectangle::Rectangle(float w, float h) | ||
{ | ||
width = w; height = h; | ||
} | ||
void Rectangle::Input(istream& inDev) | ||
{ | ||
inDev >> width >> height; | ||
} | ||
float Rectangle::Area() | ||
{ | ||
return width * height; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef _Rectangle_h | ||
#define _Rectangle_h | ||
#include "Figure.h" | ||
class Rectangle: public Figure | ||
{ | ||
protected: | ||
float width, height; | ||
public: | ||
Rectangle(float w = 0, float h = 0); | ||
virtual float Area(); | ||
virtual void Input(istream& inDevice); | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "Square.h" | ||
|
||
Square::Square(float a) | ||
{ | ||
width = height = a; | ||
} | ||
void Square::Input(istream& inDev) | ||
{ | ||
inDev >> width; | ||
height = width; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef _Square_h | ||
#define _Square_h | ||
#include "Rectangle.h" | ||
|
||
class Square : public Rectangle | ||
{ | ||
public: | ||
Square(float a = 0); | ||
virtual void Input(istream& inDevice); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "Triangle.h" | ||
Triangle::Triangle(float a, float h) | ||
{ | ||
basesize = 0; height = h; | ||
} | ||
void Triangle::Input(istream& inDev) | ||
{ | ||
inDev >> basesize >> height; | ||
} | ||
float Triangle::Area() | ||
{ | ||
return basesize * height / 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef _Triangle_h | ||
#define _Triangle_h | ||
#include "Figure.h" | ||
class Triangle: public Figure | ||
{ | ||
protected: | ||
float basesize, height; | ||
public: | ||
Triangle(float a = 0, float h = 0); | ||
virtual float Area(); | ||
virtual void Input(istream& inDev); | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cd polyV5RectangleSquare/ | ||
g++ MainProgRecSqua.cpp Triangle.cpp Circle.cpp Ellipse.cpp Square.cpp Rectangle.cpp; ./a.out | ||
cd .. |