-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPolygon.h
More file actions
58 lines (47 loc) · 1.86 KB
/
Polygon.h
File metadata and controls
58 lines (47 loc) · 1.86 KB
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
//************************************************************
// Polygon.h
// Polymorphism_Project
//
// Created by Karlina Beringer on July 13, 2014.
//
// This header file contains the declaration for Polygon.
// Polygon is an abstract class.
// An abstract class has AT LEAST one virtual function.
// Polygon also includes Point via composition.
//************************************************************
#ifndef Polygon_h
#define Polygon_h
#include "Point.h"
//------------------------------------------------------------
// Let Polygon be a generic "template" for cyclic polygons.
//------------------------------------------------------------
class Polygon
{
protected:
// Type is a description of the Polygon instance.
const string TYPE = "POLYGON";
// Color is an arbitrary value.
// It's being used to demonstrate abstract constructors.
string color;
public:
// Default constructor initializes the color.
// We cannot instantiate Polygon since it's abstract.
// Instead, the constructor is used by descendants.
Polygon();
// Getter method prints a description of the Polygon.
// If no parameter is supplied, output goes to console.
void print( ostream & output = cout );
// Friend function alternative to the print method.
// Overloads the ostream operator.
// Friend is NOT a member of this class, but has access.
friend ostream & operator << (ostream & out, Polygon & P);
//--------------------------------------------------------
// Virtual methods must be defined by derived classes.
//--------------------------------------------------------
virtual double getArea() = 0;
virtual double getPerimeter() = 0;
};
#endif
//************************************************************
// End of File
//************************************************************