-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPostgraduateStudent_Task3.cpp
82 lines (63 loc) · 3.09 KB
/
PostgraduateStudent_Task3.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 "PostgraduateStudent_Task3.h" // class implemented
using namespace std;
// File scope starts here
/////////////////////////////// PUBLIC ///////////////////////////////////////
//============================= LIFECYCLE ====================================
// PostgraduateStudent Default+Overloaded Constructor
PostgraduateStudent::PostgraduateStudent(char* aName, int aAge, char aGender, char* aDesignation, char* aProgram, int aStudyYear, int aProgramLength) : Student(aName, aAge, aGender, aDesignation, aProgram, aStudyYear), mProgramLength(aProgramLength) {
this->SetPostgraduateStudent(aProgramLength);
}
// end PostgraduateStudent constructor
// PostgraduateStudent Copy Constructor
PostgraduateStudent::PostgraduateStudent(const PostgraduateStudent& rhs) : Student(rhs.GetStudent()), mProgramLength(rhs.GetProgramLength()) {
this->SetPostgraduateStudent(rhs.GetProgramLength());
}
// end PostgraduateStudent constructor
// PostgraduateStudent assignment operator.
PostgraduateStudent& PostgraduateStudent::operator =(const PostgraduateStudent& rhs) {
this->SetPostgraduateStudent(rhs.GetPostgraduateStudent());
return *this;
}
// end PostgraduateStudent assignment operator.
//============================= OPERATIONS ===================================
// function that depicts teaching of PostgraduateStudent.
void PostgraduateStudent::Teach() {
cout << this->GetName() << " is teaching." << endl;
}
// end function Teach
//============================= ACESS ===================================
// function that sets program length of PostgraduateStudent
void PostgraduateStudent::SetProgramLength(int aProgramLength) {
if (aProgramLength >= 0 && aProgramLength <= 4)
this->mProgramLength = aProgramLength;
else
cout << "Error: Program length out of range." << endl;
}
// end function SetProgramLength
// function that sets PostgraduateStudent
void PostgraduateStudent::SetPostgraduateStudent(char* aName, int aAge, char aGender, char* aProgram, int aStudyYear, int aProgramLength) {
this->SetStudent(aName, aAge, aGender, aProgram, aStudyYear);
this->SetPostgraduateStudent(aProgramLength);
}
// end function SetPostgraduateStudent
// overloaded function that sets the PostgraduateStudent
void PostgraduateStudent::SetPostgraduateStudent(int aProgramLength) {
this->SetProgramLength(aProgramLength);
}
// end function SetPostgraduateStudent
// overloaded function that sets the PostgraduateStudent
void PostgraduateStudent::SetPostgraduateStudent(const PostgraduateStudent& aPostgraduateStudent) {
this->SetStudent(aPostgraduateStudent.GetStudent());
this->SetPostgraduateStudent(aPostgraduateStudent.GetProgramLength());
}
// end function SetPostgraduateStudent
// function that gets program length of PostgraduateStudent
int PostgraduateStudent::GetProgramLength()const {
return this->mProgramLength;
}
// end function GetProgramLength
// function that gets the PostgraduateStudent
const PostgraduateStudent& PostgraduateStudent::GetPostgraduateStudent()const {
return *this;
}
// end function GetPostgraduateStudent