forked from daneos/laborki_uml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
57 lines (45 loc) · 1.15 KB
/
main.cpp
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
#include <stdio.h>
#include "ComplexShape.h"
#include "Circle.h"
#include "Rect.h"
#include "Point.h"
void draw(Shape *s, Point *start, Point *end, int resX, int resY)
{
float diffX = (end->getX() - start->getX()) / resX;
float diffY = (end->getY() - start->getY()) / resY;
printf("diff = %f;%f\n\n", diffX, diffY);
printf("-----------------------------------------------------------------------\n");
for(float y = start->getY(); y >= end->getY(); y += diffY)
{
for(float x = start->getX(); x <= end->getX(); x += diffX)
{
Point p(x, y);
if(s->isIn(&p))
printf("X");
else
printf(" ");
}
printf("\n");
}
printf("-----------------------------------------------------------------------\n");
}
int main(int argc, char *argv[])
{
printf("main: arrived\n");
Circle *c = new Circle(3);
Rect *r = new Rect(14, 2);
ComplexShape *cs = new ComplexShape(c, r, SYMMETRIC_DIFF);
Point r_pos(-4, 2);
r->setPosition(r_pos);
Point c_pos(0, -1);
c->setPosition(c_pos);
Point cs_pos(1, -3);
cs->setPosition(cs_pos);
Point start(-10, 5);
Point end(10, -5);
draw(cs, &start, &end, 40, 20);
delete cs;
delete c;
delete r;
return 0;
}