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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
| #include<iostream.h>
#include<conio.h>
#include<string.h>
enum Shape{prizm,parallelepiped,cube,pyramid,cone,cylinder};
enum Color{red,yellow,green,blue,white};
enum Material{metal,wood,plastic,cardboard};
enum Filter{water,milk,air,quartz_sand,vegetable_oil};
const char* NameShapes[cylinder+1]={"prizm","parallelepiped","cube","pyramid","cone","cylinder"};
const char* NameColors[white+1]={"red","yellow","green","blue","white"};
const char* NameMaterials[cardboard+1]={"metal","wood","plastic","cardboard"};
const char* NameFilters[vegetable_oil+1]={"water","milk","air","quartz_sand","vegetable_oil"};
const float p1[cardboard+1]={7.874,0.861,1.235,0.689};
const float p2[vegetable_oil+1]={1.0,1.032,0.001293,2.65,0.87};
const float k[cylinder+1]={1.0,1.0,1.0,1.0/3.0,1.0/3.0,1.0};
class Body
{
private:
char* name;
Shape shape;
Color color;
Material material;
Filter filter;
float H,So,Sb,Sp,thickness;
public:
Body(char* name,Shape shape,Color color,Material material);
Body(char* name,Shape shape,Color color,Material material, Filter filter,float thickness);
~Body();
float GetV1();
float GetV2();
float GetP1();
float GetP2();
const char* DisplayShape();
const char* DisplayColor();
const char* DisplayMaterial();
const char* DisplayFilter();
void Dispaly();
float get_H(float H);
float get_So(float So);
float get_Sb(float Sb);
float get_Sp(float Sp);
};
Body::Body(char* name,Shape shape,Color color,Material material)
{}
Body::Body(char* name,Shape shape,Color color,Material material, Filter filter,float thickness)
{}
Body::~Body()
{
if(this->name!=NULL)
delete[]this->name;
}
float Body::GetV1()
{return H*So*k[shape];}
float Body::GetV2()
{return Sp*thickness;}
float Body::GetP1()
{return p1[material]*GetV1();}
float Body::GetP2()
{return GetP1()+p2[filter]*(GetV1()-GetV2());}
const char* Body::DisplayShape()
{return NameShapes[shape];}
const char* Body::DisplayColor()
{return NameColors[color];}
const char* Body::DisplayMaterial()
{return NameMaterials[material];}
const char* Body::DisplayFilter()
{return NameFilters[filter];}
void Body::Dispaly()
{
cout<<name<<endl;
cout<<shape<<endl;
cout<<So<<endl;
cout<<Sb<<endl;
cout<<Sp<<endl;
cout<<GetV1()<<endl;
cout<<GetP1()<<endl;
cout<<"Hello! I`m an object "<<name<<" - "<<DisplayColor()<<' '<<
DisplayMaterial()<<' '<<DisplayShape()<<".\n";
}
float Body::get_H(float H)
{ this->H=H;
return H; }
float Body::get_So(float So)
{ this->So=So;
return So; }
float Body::get_Sb(float Sb)
{ this->Sb=Sb;
return Sb; }
float Body::get_Sp(float Sp)
{ this->Sp=Sp;
return Sp; }
class class_prizm: public Body
{
public:
class_prizm(char* name,Shape shape,Color color,Material material,float H,float So,float Sb,float Sp): Body(name,shape,color,material)
{
get_H(H);
get_So(So);
get_Sb(Sb);
get_Sp(Sp);
}
class_prizm(char* name,Shape shape,Color color,Material material,Filter filter,float thickness,float H,float So,float Sb,float Sp): Body(name,shape,color,material,filter,thickness)
{
get_H(H);
get_So(So);
get_Sb(Sb);
get_Sp(Sp);
}
};
int main()
{
class_prizm pri("Mama",cube,blue,plastic,air,1.0,1.0,1.0,1.0,1.0);
pri.Dispaly();
getch();
return 0;
} |