This repository was archived by the owner on Dec 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.cpp
More file actions
77 lines (64 loc) · 1.42 KB
/
test.cpp
File metadata and controls
77 lines (64 loc) · 1.42 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <cstdint>
#include <iostream>
using namespace std;
class Shape
{
private:
uint32_t argb;
protected:
Shape() : argb(0xffffffff) {}
public:
uint32_t get_argb() const { return argb; }
void set_argb(uint32_t argb) { this->argb = argb; }
virtual void draw() = 0;
};
class Point : public Shape
{
private:
float x;
float y;
public:
Point() : x(0.0f), y(0.0f) {}
float get_x() const { return x; }
void set_x(float x) { this->x = x; }
float get_y() const { return y; }
void set_y(float y) { this->y = y; }
virtual void draw() { cout << "Point\n"; }
};
class Circle : public Point
{
private:
float radius;
public:
Circle() : radius(0.0f) {}
float get_radius() const { return radius; }
void set_radius(float radius) { this->radius = radius; }
virtual void draw() { cout << "Circle\n"; }
};
class Line : public Shape
{
private:
float x1;
float y1;
float x2;
float y2;
public:
Line() : x1(0.0f), y1(0.0f), x2(0.0f), y2(0.0f) {}
float get_x1() { return x1; }
void set_x1(float x1) { this->x1 = x1; }
float get_y1() { return y1; }
void set_y1(float y1) { this->y1 = y1; }
float get_x2() { return x2; }
void set_x2(float x2) { this->x2 = x2; }
float get_y2() { return y2; }
void set_y2(float y2) { this->y2 = y2; }
};
int main()
{
Shape * shapes[] = { new Point(), new Circle() };
for(int i = 0; i < sizeof(shapes) / sizeof(shapes[0]); i ++) {
shapes[i]->draw();
delete shapes[i];
}
return 0;
}