-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTriangle_Task2.cpp
82 lines (65 loc) · 2.37 KB
/
Triangle_Task2.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "Triangle_Task2.h" // class implemented
using namespace std;
// File scope starts here
/////////////////////////////// PUBLIC ///////////////////////////////////////
//============================= LIFECYCLE ====================================
// Triangle Default+Overloaded Constructor
Triangle::Triangle(char* aColor, int aCoord, float aAngle) : Shape(aColor, aCoord), mAngle(aAngle) {
this->SetTriangle(aAngle);
}
// end Triangle constructor
// Triangle Copy Constructor
Triangle::Triangle(const Triangle& rhs) : Shape(rhs.GetShape()), mAngle(rhs.GetAngle()) {
this->SetTriangle(rhs.GetAngle());
}
// end Triangle constructor
// Triangle assignment operator.
Triangle& Triangle:: operator =(const Triangle& rhs) {
this->SetTriangle(rhs.GetTriangle());
return *this;
}
// end Triangle assignment operator.
//============================= OPERATIONS ===================================
// Pure virtual function that draws Triangle.
void Triangle::Draw() {
cout << "Drawing an equilateral Triangle of angle " << this->GetAngle() << " in " << this->GetColor() << " color." << endl;
}
// end function Draw
// function that computes area of Triangle.
void Triangle::ComputeArea() {
cout << "Computing the area of Triangle with angle " << this->GetAngle() << " ." << endl;
}
// end function ComputeArea
//============================= ACESS ===================================
// function that sets angles of Triangle
void Triangle::SetAngle(float aAngle) {
this->mAngle = aAngle;
}
// end function SetAngle
// function that sets Triangle
void Triangle::SetTriangle(char* aColor, int aCoord, float aAngle) {
this->SetShape(aColor, aCoord);
this->SetTriangle(aAngle);
}
// end function SetTriangle
// overloaded function that sets the Triangle
void Triangle::SetTriangle(float aAngle) {
this->SetAngle(aAngle);
}
// end function SetTriangle
// overloaded function that sets the Triangle
void Triangle::SetTriangle(const Triangle& aTriangle) {
this->SetShape(aTriangle.GetShape());
this->SetTriangle(aTriangle.GetAngle());
}
// end function SetTriangle
// function that gets angle of Triangle
float Triangle::GetAngle()const {
return this->mAngle;
}
// end function GetAngle
// function that gets the Triangle
const Triangle& Triangle::GetTriangle()const {
return *this;
}
// end function GetTriangle