|
|
 |
|
|
|
|
26: long GetArea() { return 3 * itsRadius * itsRadius; }
27: long GetPerim() { return 9 * itsRadius; }
28: void Draw();
29: private:
30: int itsRadius;
31: int itsCircumference;
32: };
33:
34: void Circle::Draw()
35: {
36: cout << Circle drawing routine here!\n;
37: Shape::Draw();
38: }
39:
40:
41: class Rectangle : public Shape
42: {
43: public:
44: Rectangle(int len, int width):
45: itsLength(len), itsWidth(width){}
46: virtual ~Rectangle(){}
47: long GetArea() { return itsLength * itsWidth; }
48: long GetPerim() {return 2*itsLength + 2*itsWidth; }
49: virtual int GetLength() { return itsLength; }
50: virtual int GetWidth() { return itsWidth; }
51: void Draw();
52: private:
53: int itsWidth;
54: int itsLength;
55: };
56:
57: void Rectangle::Draw()
58: {
59: for (int i = 0; i<itsLength; i++)
60: {
61: for (int j = 0; j<itsWidth; j++)
62: cout << × ;
63:
64: cout << \n;
65: }
66: Shape::Draw();
67: }
68:
69:
70: class Square : public Rectangle
71: {
72: public: |
|
|
|
 |
|
|
|
|
continues |
|
|
|
|
|