This repository was archived by the owner on Oct 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent.cpp
More file actions
167 lines (130 loc) · 3.43 KB
/
Copy pathstudent.cpp
File metadata and controls
167 lines (130 loc) · 3.43 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
//
// Created by Tyler Gautney on 8/5/21.
//
#include<iostream>
#include<string>
#include <utility>
#include "student.h"
using namespace std;
//default constructor that sets all variables to empty strings
Student::Student()
{
this->setStudentID("");
this->setFirstName("");
this->setLastName("");
this->setEmail("");
this->setAge(0);
int defaultDaysInCourse[3] = {0,1,2};
this->setDaysInCourse(defaultDaysInCourse);
this->setDegreeProgram(NETWORK);
}
//overloaded constructor
Student::Student(string studentID, string firstName, string lastName, string email,
int age, int daysInCourse[3], DegreeProgram degree)
{
// Using the move keyword from the std namespace prevents unnecessary copying of the variable
// Ideally, I'd pass these strings as reference parameters, but this created a bug that caused a segmentation fault
this->setStudentID(move(studentID));
this->setFirstName(move(firstName));
this->setLastName(move(lastName));
this->setEmail(move(email));
this->setAge(age);
this->setDaysInCourse(daysInCourse);
this->setDegreeProgram(degree);
}
//Class Mutators for each variable
void Student::setStudentID(string newID)
{
this->studentID = move(newID);
}
void Student::setFirstName(string newFirstName)
{
this->firstName = move(newFirstName);
}
void Student::setLastName(string newLastName)
{
this->lastName = move(newLastName);
}
void Student::setEmail(string newEmail)
{
this->email = move(newEmail);
}
void Student::setAge(int newAge)
{
this->age = newAge;
}
void Student::setDaysInCourse(const int updatedDaysInCourse[3])
{
for (int index=0; index<3; index++)
this->daysInCourse[index] = updatedDaysInCourse[index];
}
void Student::setDegreeProgram(DegreeProgram updatedDegree)
{
this->degree = updatedDegree;
}
//Accessor Functions for each variable
string Student::getStudentID() const
{
return this->studentID;
}
string Student::getFirstName() const
{
return this->firstName;
}
string Student::getLastName() const
{
return this->lastName;
}
string Student::getFullName() const
{
string fullName = this->getFirstName() + ' ' + this->getLastName();
return fullName;
}
string Student::getEmail() const
{
return this->email;
}
unsigned int Student::getAge() const
{
return this->age;
}
int Student::getAverageDaysInCourse() const
{
int averageDaysInCourse = 0;
for (int index : this->daysInCourse) averageDaysInCourse += index;
averageDaysInCourse /= 3;
return averageDaysInCourse;
}
int Student::getDaysInCourse(unsigned int index) const
{
return this->daysInCourse[index];
}
DegreeProgram Student::getDegreeProgram() const
{
return this->degree;
}
void Student::print() const
{
cout << this->getStudentID() << " \t";
cout << "First Name: " << this->getFirstName() << " \t";
cout << "Last Name: " << this->getLastName() << " \t";
cout << "Age: " << this->getAge() << " \t";
cout << "daysInCourse: {";
for (int i=0; i<3; i++) cout << this->getDaysInCourse(i) << ',';
cout <<"} \t";
cout << "Degree Program: ";
switch(this->getDegreeProgram())
{
case 0:
cout << "Security" << endl;
break;
case 1:
cout << "Networking" << endl;
break;
case 2:
cout << "Software" << endl;
break;
default:
cout << "Unspecified" << endl;
}
}