-
Notifications
You must be signed in to change notification settings - Fork 0
/
Circle.h
55 lines (48 loc) · 1.5 KB
/
Circle.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 CIRCLE_H
#define CIRCLE_H
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<sstream>
#include<string.h>
#include<vector>
#include "ShapeTwoD.h"
#include "Point.h"
using namespace std;
class Circle: public ShapeTwoD{
public:
vector<Point*> plist;
Point* center;
int radius;
Circle(){};
Circle(string name, bool cws, int id, vector<Point*>alist, int radius)
:ShapeTwoD("Circle", cws, id){
plist = alist;
center = plist[0];
this->radius = radius;
plist.push_back(new Point(center->x - radius, center->y));
plist.push_back(new Point(center->x, center->y - radius));
plist.push_back(new Point(center->x + radius, center->y));
plist.push_back(new Point(center->x, center->y + radius));
for(int i = center->x-radius; i <= center->x +radius; i++){
for(int j= center->y -radius; j <= center->y +radius; j++){
if(isPointInShape(i,j)){
plist.push_back(new Point(i, j));
}
}
}
}
double ComputeArea();
string toString();
bool isPointInShape(int x,int y);
bool isPointOnShape(int x,int y);
vector<Point*> getList();
~Circle() {
cout << "Delete circle" << endl;
for(int i=0; i<plist.size(); i++) {
delete plist[i];
}
}
};
#endif