-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathproduct_cpp.h
55 lines (42 loc) · 871 Bytes
/
product_cpp.h
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
#ifndef _PRODUCT_CPP_H_
#define _PRODUCT_CPP_H_
class Shape {
public:
int x, y;
const char* name;
public:
Shape(int _x, int _y, const char* _name) : x(_x), y(_y), name(_name) {}
virtual ~Shape() {}
static int born(int a)
{
return 0;
}
int move(int x, int y)
{
this->x += x;
this->y += y;
return 0;
}
int move(int xy);
virtual const char* print() = 0;
};
class Rect : public Shape {
public:
int width, height;
public:
Rect(int left, int top, int _width, int _height) : Shape(left, top, "Rect"), width(_width), height(_height)
{
}
void scale(double x)
{
width = (int)(width * x);
height = (int)(height * x);
}
const char* print()
{
return "Rect";
}
int serialize(unsigned char* buffer, int length);
void dump(const char* filename);
};
#endif