-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgshape.hpp
100 lines (73 loc) · 1.83 KB
/
gshape.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef GSHAPE_H_
#define GSHAPE_H_
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<list>
#include<fstream>
#include <iomanip>
using namespace std;
class GShape{
public:
GShape(string name);
string getName();
virtual double getArea() const = 0;
virtual double getVolume() const = 0;
private:
string name_;
};
class GRectangle : public GShape{
public:
GRectangle(double width = 0, double length = 0);
virtual double getArea() const;
virtual double getVolume() const;
GRectangle operator + (const GRectangle& rec);
GRectangle operator - (const GRectangle& rec);
double getWidth() const;
double getLength() const;
private:
double width_;
double length_;
};
class GCircle : public GShape{
public:
GCircle(double radius);
virtual double getArea() const;
virtual double getVolume() const;
GCircle operator + (const GCircle& cir);
GCircle operator - (const GCircle& cir);
double getRadius() const;
private:
double radius_;
};
class GSphere : public GShape{
public:
GSphere(double radius);
virtual double getVolume() const;
virtual double getArea() const;
GSphere operator + (const GSphere& sph);
GSphere operator - (const GSphere& sph);
double getRadius() const;
private:
double radius_;
};
class GRectPrism : public GShape{
public:
GRectPrism(double width, double length, double height);
virtual double getVolume() const;
virtual double getArea() const;
GRectPrism operator + (const GRectPrism& rectp);
GRectPrism operator - (const GRectPrism& rectp);
double getWidth() const;
double getLength() const;
double getHeight() const;
private:
double length_;
double width_;
double height_;
};
list<GShape*> CreateGShapesGold(char* file_name);
double MaxAreaGold(list<GShape*> shapes);
double MaxVolumeGold(list<GShape*> shapes);
#endif