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

Teacher file updates

parent bce03cab
......@@ -6,7 +6,8 @@ Teacher::Teacher(string userNameIn) {
}
void Teacher::displayMenu() {
cout << "Teacher Menu" << endl;
cout << "____________" << endl;
}
void Teacher::displayProgress() {
......@@ -17,16 +18,50 @@ void Teacher::displayProgress() {
}
}
bool Teacher::exportProgress() {
void Teacher::exportProgress() {
}
bool Teacher::enrollStudent(Student studentIn) {
roster.push_back(studentIn);
void Teacher::enrollStudent(Student 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() {
......@@ -43,10 +78,10 @@ const string Teacher::getExitCode() {
}
// Mutators
bool Teacher::setExitCode(string exitCodeIn) {
void Teacher::setExitCode(string exitCodeIn) {
exitCode = exitCodeIn;
}
bool Teacher::setUserName(string userNameIn) {
void Teacher::setUserName(string userNameIn) {
userName = userNameIn;
}
\ No newline at end of file
......@@ -36,9 +36,9 @@ class Teacher {
// Teacher Functions
void displayMenu();
void displayProgress(); // Opens menu, teacher get get all (gradebook style) or a student
bool exportProgress(); // outputProgress() in UML
bool enrollStudent(Student studentIn);
bool adjustProgress(Student studentIn, int level);
void exportProgress(); // outputProgress() in UML
void enrollStudent(Student studentIn);
void adjustProgress(string studentUserNameIn, int level);
void endProgram();
// Accessors
......@@ -46,8 +46,8 @@ class Teacher {
const string getExitCode();
// Mutators
bool setExitCode(string exitCodeIn);
bool setUserName(string userNameIn);
void setExitCode(string exitCodeIn);
void setUserName(string userNameIn);
private:
string userName;
......
......@@ -28,10 +28,16 @@ int main() {
testTeacher.enrollStudent(studentIn);
}
//Student studentIn("Andrew");
//testTeacher.enrollStudent(studentIn);
cout << "\nNow we will test the displayProgress() function.\n";
testTeacher.displayProgress();
testTeacher.adjustProgress("Andrew",5);
testTeacher.displayProgress();
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