forked from jordi-petit/ap2-moduls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cc
216 lines (149 loc) · 5.82 KB
/
main.cc
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#include <iostream>
#include <string>
#include <map>
#include <cassert>
using namespace std;
#include "Point.hh"
#include "Rectangle.hh"
#include "Circle.hh"
// ************************************************************************************
void point_def (map<string, Point>& points) {
string name;
double x, y;
cin >> name >> x >> y;
points[name] = Point(x, y);
}
void point_copy (map<string, Point>& points) {
string name1, name2;
cin >> name1 >> name2;
points[name1] = points[name2];
}
void point_get_x (map<string, Point>& points) {
string name;
cin >> name;
cout << points[name].get_x() << endl;
}
void point_get_y (map<string, Point>& points) {
string name;
cin >> name;
cout << points[name].get_y() << endl;
}
void point_radius (map<string, Point>& points) {
string name;
cin >> name;
cout << points[name].radius() << endl;
}
void point_angle (map<string, Point>& points) {
string name;
cin >> name;
cout << points[name].angle() << endl;
}
void point_distance (map<string, Point>& points) {
string name1, name2;
cin >> name1 >> name2;
cout << points[name1].distance(points[name2]) << endl;
}
void point_eq (map<string, Point>& points) {
string name1, name2;
cin >> name1 >> name2;
cout << (points[name1] == points[name2]) << endl;
}
void point_ne (map<string, Point>& points) {
string name1, name2;
cin >> name1 >> name2;
cout << (points[name1] != points[name2]) << endl;
}
void point_add (map<string, Point>& points) {
string name1, name2;
cin >> name1 >> name2;
points[name1] += points[name2];
}
// ************************************************************************************
void rect_def (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_copy (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_get_LL (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_get_UR (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_width (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_height (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_area (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_scale (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_move_to (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_eq (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_ne (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_intersec (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_rotate (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_flip_hor (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_flip_ver (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_contains_point (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
void rect_contains_rect (map<string, Point>& points, map<string, Rectangle>& rects) {
// Implement me !!!
}
// ************************************************************************************
int main () {
map<string, Point> points;
map<string, Rectangle> rects;
string action;
while (cin >> action) {
if (action == "point_def") point_def(points);
else if (action == "point_copy") point_copy(points);
else if (action == "point_get_x") point_get_x(points);
else if (action == "point_get_y") point_get_y(points);
else if (action == "point_radius") point_radius(points);
else if (action == "point_angle") point_angle(points);
else if (action == "point_distance") point_distance(points);
else if (action == "point_eq") point_eq(points);
else if (action == "point_ne") point_ne(points);
else if (action == "point_add") point_add(points);
else if (action == "rect_def") rect_def(points, rects);
else if (action == "rect_copy") rect_copy(points, rects);
else if (action == "rect_get_LL") rect_get_LL(points, rects);
else if (action == "rect_get_UR") rect_get_UR(points, rects);
else if (action == "rect_width") rect_width(points, rects);
else if (action == "rect_height") rect_height(points, rects);
else if (action == "rect_area") rect_area(points, rects);
else if (action == "rect_scale") rect_scale(points, rects);
else if (action == "rect_move_to") rect_move_to(points, rects);
else if (action == "rect_eq") rect_eq(points, rects);
else if (action == "rect_ne") rect_ne(points, rects);
else if (action == "rect_intersec") rect_intersec(points, rects);
else if (action == "rect_rotate") rect_rotate(points, rects);
else if (action == "rect_flip_hor") rect_flip_hor(points, rects);
else if (action == "rect_flip_ver") rect_flip_ver(points, rects);
else if (action == "rect_contains_point") rect_contains_point(points, rects);
else if (action == "rect_contains_rect") rect_contains_rect(points, rects);
else assert(false);
/** Extend for Circle !!! **/
}
}