-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.cpp
More file actions
325 lines (303 loc) · 9.15 KB
/
Student.cpp
File metadata and controls
325 lines (303 loc) · 9.15 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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
/*********************************************************
* file name: Student.cpp
* programmer name: Jack Kwok
* date created:2/5/2020
* date of last revision:2/5/2020
* details of the revision: None
* short description: This implementation file writes the functions for the Student class.
**********************************************************/
#include <string>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include "Student.h"
using namespace std;
using namespace team3Belashov;
using namespace team3Distler;
using namespace team3Luo;
using namespace team3Kwok;
namespace team3Kwok {
//default constructor
Student::Student() {
firstName = "n/a";
middleName = "n/a";
lastName = "n/a";
studentID = 123456789;
userIDNum = "abc1234";
intendedMajor = "Computer Science";
intendedMinor = "n/a";
status = "Not Enrolled";
}
//constructor for everything
Student::Student(string firstName,
string middleName,
string lastName,
int studentID,
string userIDNum,
MailingAddress stuAddress,
Date birthDate,
Date acceptDate,
Semester startSemester,
string intendedMajor,
string intendedMinor,
string status) {
this->firstName = firstName;
this->middleName = middleName;
this->lastName = lastName;
this->studentID = studentID;
this->userIDNum = userIDNum;
this->stuAddress = stuAddress;
this->birthDate = birthDate;
this->acceptDate = acceptDate;
this->startSemester = startSemester;
this->intendedMajor = intendedMajor;
this->intendedMinor = intendedMinor;
this->status = status;
}
//Copy Constructor
Student::Student(const Student& s) {
firstName = s.firstName;
middleName = s.middleName;
lastName = s.lastName;
studentID = s.studentID;
userIDNum = s.userIDNum;
stuAddress = s.stuAddress;
for (int i = 0; i < s.emailArr.size(); i++) {
emailArr[i] = s.emailArr[i];
}
for (int i = 0; i < s.phoneArr.size(); i++) {
phoneArr[i] = s.phoneArr[i];
}
birthDate = s.birthDate;
acceptDate = s.acceptDate;
startSemester = s.startSemester;
intendedMajor = s.intendedMajor;
intendedMinor = s.intendedMinor;
status = s.status;
}
//get all student as a string
string Student::getAllStudentData() const{
string all;
all = "\nName: " + firstName + " " + middleName + " " + lastName
+ "\nStudent ID: " + to_string(studentID)
+ "\nUser ID Number: " + userIDNum
+ "\nMailing Addresses:\n";
all+= (stuAddress.getStreet() + ", "
+ stuAddress.getCity() + ", "
+ stuAddress.getState() + " "
+ to_string(stuAddress.getZip()) + " ("
+ stuAddress.getType() + ")\n\n");
all+= "\nEmails:\n";
for (int i = 0; i < emailArr.size(); i++) {
all+= emailArr[i].getAddress() + " ("
+ emailArr[i].getType() + ")\n\n";
}
all += "\nPhone Numbers:\n";
for (int i = 0; i < phoneArr.size(); i++) {
all+= phoneArr[i].getNum()+ " ("
+ phoneArr[i].getType() + ") \n";
}
all+= "\nDOB: " + to_string(birthDate.getMonth()) + "/" + to_string(birthDate.getDay()) + "/" + to_string(birthDate.getYear())
+ "\nDate Accepted: " + to_string(acceptDate.getMonth()) + "/" + to_string(acceptDate.getDay()) + "/" + to_string(acceptDate.getYear())
+ "\nStart Semester: " + startSemester.getSeason() + ", " + to_string(startSemester.getYear());
+ "\nIntended Major: " + intendedMajor
+ "\nIntended Minor: " + intendedMinor
+ "\nStatus: " + status + "\n";
all += getCourseList(courseList) + "\n\n";
return all;
}
string Student::getCourseList(CourseNode* head_ptr) const {
string temp = "";
CourseNode* cursor = NULL;
for (cursor = head_ptr; cursor != NULL; cursor = cursor->link)
{
temp = temp + "\nCourse Number: " + cursor->data.getCourseNumber();
temp = temp + "\nCourse Description: " + cursor->data.getCourseDescription();
temp = temp + "\nSemester Taken (Season): " + cursor->data.getSemesterTaken().getSeason() + "\nYear: " + to_string(cursor->data.getSemesterTaken().getYear());
temp = temp + "\nDelivery Method: " + cursor->data.getDeliveryMethod();
temp = temp + "\nCurrent Status: " + cursor->data.getCurrentStatus();
temp = temp + "\nGrade Earned: " + to_string(cursor->data.getGradeEarned()) + "\n\n";
}
return temp;
}
string Student::getSomeStudentData() const
{
string some;
some += "\nName: " + firstName + " " + middleName + " " + lastName
+ "\nStudent ID: " + to_string(studentID)
+ "\nUser ID Number: " + userIDNum;
some += getCourseListPartial(courseList) + "\n\n";
return some;
}
string Student::getCourseListPartial(CourseNode* head_ptr) const {
string temp = "";
CourseNode* cursor = NULL;
for (cursor = head_ptr; cursor != NULL; cursor = cursor->link)
{
temp = temp + "\nCourse Number: " + cursor->data.getCourseNumber();
temp = temp + "\nCourse Description: " + cursor->data.getCourseDescription();
temp = temp + "\nSemester Taken: Season: " + cursor->data.getSemesterTaken().getSeason() + " Year: " + to_string(cursor->data.getSemesterTaken().getYear());
temp = temp + "\nDelivery Method: " + cursor->data.getDeliveryMethod();
temp = temp + "\nCurrent Status: " + cursor->data.getCurrentStatus();
temp = temp + "\nGrade Earned: " + to_string(cursor->data.getGradeEarned()) + "\n\n";
}
return temp;
}
//Mutator Functions
void Student::setName(string first, string middle, string last) {
firstName = first;
middleName = middle;
lastName = last;
}
void Student::setFirstName(string first) {
firstName = first;
}
void Student::setMiddleName(string middle) {
middleName = middle;
}
void Student::setLastName(string last) {
lastName = last;
}
void Student::setStuID(int s) {
studentID = s;
}
void Student::setUserID(string u) {
userIDNum = u;
}
void Student::setStuAddress(MailingAddress m) {
stuAddress = m;
}
void Student::setBirthDate(int m, int d, int y) {
birthDate.setMonth(m);
birthDate.setDay(d);
birthDate.setYear(y);
}
void Student::setAcceptanceDate(int m, int d, int y) {
acceptDate.setMonth(m);
acceptDate.setDay(d);
acceptDate.setYear(y);
}
void Student::setStartSemester(Semester s) {
startSemester = s;
}
void Student::setIntendedMajor(string iM) {
intendedMajor = iM;
}
void Student::setIntendedMinor(string iM) {
intendedMinor = iM;
}
void Student::setStatus(string s) {
status = s;
}
//Accessor Functions
string Student::getFirstName() const {
return firstName;
}
string Student::getMiddleName() const {
return middleName;
}
string Student::getLastName() const {
return lastName;
}
int Student::getStuID() const {
return studentID;
}
string Student::getUserID() const {
return userIDNum;
}
MailingAddress Student::getStuAddress() const {
return stuAddress;
}
Date Student::getBirthDate() const {
return birthDate;
}
Date Student::getAcceptanceDate() const {
return acceptDate;
}
Semester Student::getStartSemester() const {
return startSemester;
}
string Student::getIntendedMajor() const {
return intendedMajor;
}
string Student::getIntendedMinor() const {
return intendedMinor;
}
string Student::getStatus() const {
return status;
}
//insert functions
void Student::insertEmail(Email e) {
emailArr.push_back(e);
}
void Student::insertPhoneNum(PhoneNumber p) {
phoneArr.push_back(p);
}
//file.io
void Student::writeFile(ofstream& outFile) {
outFile << firstName << "\n" << middleName << "\n" << lastName << "\n";
//UNFINISHED
}
void Student::readFile(ifstream& inFile)/*need to add course*/ {
//name input
getline(inFile, firstName);
getline(inFile, middleName);
getline(inFile, lastName);
//id input
inFile >> studentID;
inFile.ignore();
getline(inFile, userIDNum);
//address input
string input;
getline(inFile, input);
stuAddress.setStreet(input);
getline(inFile, input);
stuAddress.setCity(input);
getline(inFile, input);
stuAddress.setState(input);
int num;
inFile >> num;
stuAddress.setZip(num);
inFile.ignore();
getline(inFile, input);
stuAddress.setType(input);
//birth date input
int m, d, y;
inFile >> m >> d >> y;
setBirthDate(m, d, y);
//acceptance date input
inFile >> m >> d >> y;
setAcceptanceDate(m, d, y);
//start semester
inFile >> input >> num;
Semester startSemester(input, num);
setStartSemester(startSemester);
//intended major
inFile.ignore();
getline(inFile, input);
setIntendedMajor(input);
//intended minor
getline(inFile, input);
setIntendedMinor(input);
//status
getline(inFile, input);
setStatus(input);
//email address loop
inFile >> num;
for (int i = 0; i < num; i++) {
string emailName, emailType;
inFile >> emailName >> emailType;
Email emailAdd(emailName, emailType);
insertEmail(emailAdd);
}
//phone number loop
inFile >> num;
for (int i = 1; i <= num; i++) {
string phoneNumber, phoneType;
inFile >> phoneNumber >> phoneType;
PhoneNumber phoneNum(phoneNumber, phoneType);
insertPhoneNum(phoneNum);
}
inFile.ignore();
}
}