-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudent.cpp
140 lines (130 loc) · 3.41 KB
/
student.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//source file for student class, includes definitions
#include <iostream>
#include <string>
#include <iomanip>
#include "degree.h"
#include "student.h"
using namespace std;
//getter functions
int Student::getAge() {
return age;
}
string Student::getLastName() {
return lastName;
}
string Student::getFirstName() {
return firstName;
}
string Student::getEmail() {
return email;
}
string Student::getStudentID() {
return studentID;
}
int* Student::getNumberOfDays() {
return numberOfDays;
}
DegreeProgram Student::getDegreeProgram() {
return degree;
}
//setter functions
void Student::setAge(int newAge) {
this->age = newAge;
}
void Student::setLastName(string newLastName) {
this->lastName = newLastName;
}
void Student::setFirstName(string newFirstName) {
this->firstName = newFirstName;
}
void Student::setEmail(string newEmail) {
this->email = newEmail;
}
void Student::setStudentID(string newstudentID) {
this->studentID = newstudentID;
}
void Student::setNumberOfDays(int* newNumberOfDays) {
for (int i = 0; i < daysArraySize; i++) {
this->numberOfDays[i] = newNumberOfDays[i];
}
}
void Student::setDegreeProgram(DegreeProgram newDegreeProgram) {
this->degree = newDegreeProgram;
}
//print function, input desired print information and outputs
void Student::print(string printInfo) {
if (printInfo == "age") {
cout << this->getAge() << "\t" ;
}
else if (printInfo == "lastName") {
cout << this->getLastName() << "\t" ;
}
else if (printInfo == "firstName") {
cout << this->getFirstName() << "\t" ;
}
else if (printInfo == "email") {
cout << this->getEmail() << "\t" ;
}
else if (printInfo == "studentID") {
cout << this->getStudentID() << "\t" ;
}
else if (printInfo == "numberOfDays") {
for (int i = 0; i < daysArraySize; i++) {
if (i != daysArraySize - 1) {
cout << this->getNumberOfDays()[i] << ", ";
}
else {
cout << this->getNumberOfDays()[i] << "\t" ;
}
}
}
else if (printInfo == "DegreeProgram") {
cout << degreeString[(int)degree] << "\t" ;
}
//uses iomanip to make output look pretty
else if (printInfo == "all") {
cout << setw(3) << this->getStudentID() << '|';
cout << setw(10) << this->getFirstName() << '|';
cout << setw(10) << this->getLastName() << '|';
cout << setw(25) << this->getEmail() << '|';
cout << setw(4) << this->getAge() << '|';
for (int i = 0; i < daysArraySize; i++) {
if (i != daysArraySize - 1) {
cout << setw(3) << this->getNumberOfDays()[i] << ", ";
}
else {
cout << setw(3) << this->getNumberOfDays()[i] << '|';
}
}
cout << setw(10) << degreeString[(int)degree] << '|';
}
else {
cout << "Invalid entry for string printInfo parameter." << endl;
}
}
//default constructor, constructor and destructor
Student::Student() {
this->age = 0;
this->lastName = "n/a";
this->firstName = "n/a";
this->email = "n/a";
this->studentID = "n/a";
for (int i = 0; i < daysArraySize; i++) {
this->numberOfDays[i] = 0;
}
this->degree = DegreeProgram::None;
}
Student::Student(string studentID, string firstName, string lastName, string email, int age, int *numberOfDays, DegreeProgram degree) {
this->age = age;
this->lastName = lastName;
this->firstName = firstName;
this->email = email;
this->studentID = studentID;
for (int i = 0; i < daysArraySize; i++) {
this->numberOfDays[i] = numberOfDays[i];
}
this->degree = degree;
}
Student::~Student() {
cout << "Student destructor for " << this->studentID << " called." << endl;
}