Commit 41a2240d authored by Andrew Binder's avatar Andrew Binder

Teacher file updates

parent bce03cab
...@@ -6,7 +6,8 @@ Teacher::Teacher(string userNameIn) { ...@@ -6,7 +6,8 @@ Teacher::Teacher(string userNameIn) {
} }
void Teacher::displayMenu() { void Teacher::displayMenu() {
cout << "Teacher Menu" << endl;
cout << "____________" << endl;
} }
void Teacher::displayProgress() { void Teacher::displayProgress() {
...@@ -17,16 +18,50 @@ void Teacher::displayProgress() { ...@@ -17,16 +18,50 @@ void Teacher::displayProgress() {
} }
} }
bool Teacher::exportProgress() { void Teacher::exportProgress() {
} }
bool Teacher::enrollStudent(Student studentIn) { void Teacher::enrollStudent(Student studentIn) {
roster.push_back(studentIn); bool validName = 1;
for (int i = 0; i < roster.size(); i++) {
if (roster.at(i).getUserName() == studentIn.getUserName()) {
validName = 0;
}
}
if (validName) {
roster.push_back(studentIn);
cout << "Student succesfully enrolled." << endl;
} else {
cout << "Error: Student already exists!" << endl;
}
} }
bool Teacher::adjustProgress(Student studentIn, int level) { void Teacher::adjustProgress(string studentUserNameIn, int level) {
int
lastLevel = -1,
studentNumber = -1;
bool validName = 0;
for (int i = 0; i < roster.size(); i++) {
if (roster.at(i).getUserName() == studentUserNameIn) {
validName = 1;
studentNumber = i;
}
}
if (validName) {
lastLevel = roster.at(studentNumber).getLevel();
roster.at(studentNumber).setLevel(level);
cout << roster.at(studentNumber).getUserName() << "'s level was changed from level " << lastLevel << " to " << roster.at(studentNumber).getLevel() << "." << endl;
} else {
cout << "Error: Student not found!" << endl;
}
} }
void Teacher::endProgram() { void Teacher::endProgram() {
...@@ -43,10 +78,10 @@ const string Teacher::getExitCode() { ...@@ -43,10 +78,10 @@ const string Teacher::getExitCode() {
} }
// Mutators // Mutators
bool Teacher::setExitCode(string exitCodeIn) { void Teacher::setExitCode(string exitCodeIn) {
exitCode = exitCodeIn; exitCode = exitCodeIn;
} }
bool Teacher::setUserName(string userNameIn) { void Teacher::setUserName(string userNameIn) {
userName = userNameIn; userName = userNameIn;
} }
\ No newline at end of file
...@@ -36,9 +36,9 @@ class Teacher { ...@@ -36,9 +36,9 @@ class Teacher {
// Teacher Functions // Teacher Functions
void displayMenu(); void displayMenu();
void displayProgress(); // Opens menu, teacher get get all (gradebook style) or a student void displayProgress(); // Opens menu, teacher get get all (gradebook style) or a student
bool exportProgress(); // outputProgress() in UML void exportProgress(); // outputProgress() in UML
bool enrollStudent(Student studentIn); void enrollStudent(Student studentIn);
bool adjustProgress(Student studentIn, int level); void adjustProgress(string studentUserNameIn, int level);
void endProgram(); void endProgram();
// Accessors // Accessors
...@@ -46,8 +46,8 @@ class Teacher { ...@@ -46,8 +46,8 @@ class Teacher {
const string getExitCode(); const string getExitCode();
// Mutators // Mutators
bool setExitCode(string exitCodeIn); void setExitCode(string exitCodeIn);
bool setUserName(string userNameIn); void setUserName(string userNameIn);
private: private:
string userName; string userName;
......
...@@ -28,10 +28,16 @@ int main() { ...@@ -28,10 +28,16 @@ int main() {
testTeacher.enrollStudent(studentIn); testTeacher.enrollStudent(studentIn);
} }
//Student studentIn("Andrew");
//testTeacher.enrollStudent(studentIn);
cout << "\nNow we will test the displayProgress() function.\n"; cout << "\nNow we will test the displayProgress() function.\n";
testTeacher.displayProgress(); testTeacher.displayProgress();
testTeacher.adjustProgress("Andrew",5);
testTeacher.displayProgress();
return 0; return 0;
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment