-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path67.cpp
More file actions
61 lines (55 loc) · 1.12 KB
/
67.cpp
File metadata and controls
61 lines (55 loc) · 1.12 KB
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
#include<cmath>
#pragma once
class ShapeFactory
{
public:
ShapeFactory(){};
virtual ~ShapeFactory(){};
virtual float Circumstance(){return 0;};
ShapeFactory *Create(float a,float b,float c);
ShapeFactory *Create(float a,float b,float c,float d);
ShapeFactory *Create(float r);
};
#include "ShapeFactory.h"
class T:public ShapeFactory{
public:
T(float A,float B,float C){
a=A,b=B,c=C;
}
float Circumstance()override{
return a+b+c;
};
private:
float a,b,c;
};
ShapeFactory *ShapeFactory::Create(float a,float b,float c){
return new T(a,b,c);
}
class Rec:public ShapeFactory{
public:
Rec(float A,float B,float C,float D){
a=A,b=B,c=C,d=D;
}
float Circumstance()override{
return a+b+c+d;
};
private:
float a,b,c,d;
};
ShapeFactory *ShapeFactory::Create(float a,float b,float c,float d){
return new Rec(a,b,c,d);
}
class R:public ShapeFactory{
public:
R(float R){
r=R;
}
float Circumstance()override{
return 3.14f*r*2.0f;
};
private:
float r;
};
ShapeFactory *ShapeFactory::Create(float r){
return new R(r);
}