-
Notifications
You must be signed in to change notification settings - Fork 1
/
polygon.h
81 lines (62 loc) · 1.31 KB
/
polygon.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
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
/*
* polygon.h
* 4/3/2016
*
* CS 372 Sp16
* Group Project 2: Postscript Generator
*/
#ifndef POLYGON_H_INCLUDED
#define POLYGON_H_INCLUDED
#include "shape.h"
class Polygon: public Shape
{
public:
Polygon()
: Shape(),
numOfSides_(0),
sideLength_(0),
radius_(0)
{};
Polygon(int x, int y, int sides, double length)
: Shape(x, y, getWidth(sides,length),getHeight(sides,length)),
numOfSides_(sides),
sideLength_(length),
radius_(getRadius(sides,length))
{};
Polygon(int sides, double length)
: Polygon(0,0,sides,length)
{};
string draw() const;
string draw(int x,int y) const;
int numOfSides();
double sideLength();
double radius();
protected:
/**
* number of sides of the polygon
*/
int numOfSides_;
/**
* length of polygon's sides
*/
double sideLength_;
/**
* radius of polygon
*/
double radius_;
}; //end of class Polygon
class Triangle : public Polygon
{
public:
Triangle() : Polygon(0,0,3,0) {};
Triangle(int x, int y, double side) : Polygon(x,y,3,side) {};
Triangle(double side) : Triangle(0,0,side) {};
}; //end of class Triangle
class Square: public Polygon
{
public:
Square(): Polygon(0,0,4,0) {};
Square(int x, int y, double side): Polygon(x,y,4,side) {};
Square(double side) : Square(0,0,side) {};
}; //end of class Square
#endif