-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTrapezoid.h
More file actions
65 lines (51 loc) · 2.3 KB
/
Trapezoid.h
File metadata and controls
65 lines (51 loc) · 2.3 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
59
60
61
62
63
64
65
//******************************************************************************
// Trapezoid.h
// Inheritance
//
// Created by Karlina Beringer on July 10, 2014.
//
// This header file contains the Trapezoid class declaration.
// Trapezoid is derived from the Quadrilateral class.
//******************************************************************************
#ifndef Trapezoid_h
#define Trapezoid_h
#include "Quadrilateral.h"
//-----------------------------------------------------------------------------
// Trapezoid represents a quadrilateral with exactly least two parallel sides.
//-----------------------------------------------------------------------------
class Trapezoid: public Quadrilateral
{
// Trapezoid inherits the data members and methods of Quadrilateral.
private:
// Base1 is the longest parallel edge.
// Base2 is the shortest parellel edge.
// Height is the distance between parallel edges.
double base1, base2, height;
// A brief description of the class.
const string TYPE = "QUADRILATERAL/TRAPEZOID";
// Helper method forces exactly two sides to be parallel.
void setAttributes();
public:
// Default constructor calls Quadrilateral's default constructor.
Trapezoid();
// Normal constructor calls Quadrilateral's normal constructor.
Trapezoid( Point A, Point B, Point C, Point D );
// Copy constructor calls Quadrilateral's copy constructor.
Trapezoid( Quadrilateral & quad );
// Getter returns the area of this Quadrilateral.
// Override the method to customize it for Trapezoid.
// Area = [(Base1 + Base2) * Height] / 2
double getArea();
// Print the contents of this Quadrilateral.
// Override the method to customize it for Trapezoid.
// If no ostream parameter is supplied, default will be cout.
void print( ostream & output = cout );
// Friend function behaves like Trapezoid's print method.
// Overloads the ostream operator.
// Friend is NOT a member of this class, but has access to its members.
friend ostream & operator << ( ostream & output, Trapezoid & trap );
};
#endif
//******************************************************************************
// End of File
//******************************************************************************