Commit 06b24473 authored by Jared Sexton's avatar Jared Sexton

Added a MAIN program

parent 9a99c93c
/* ============================================================================
Main Function
g++ -std=c++11 MAIN.cpp Questions.cpp Teacher.cpp -o MAIN.cpp.o && ./MAIN.cpp.o
Student.cpp
============================================================================
*/
#include "Questions.h"
#include "Student.h"
#include "Teacher.h"
#include <iostream> // For cout and cin
using namespace std;
int main() {
Teacher teacher;
teacher.importProgress();
string currentUser;
bool keepRunning = true;
do {
cout << "Please enter your user name: ";
cin >> currentUser;
if (cin) {
if(currentUser == teacher.getExitCode()) {
keepRunning = false;
}
else if (currentUser == teacher.getUserName()) {
do {
teacher.displayMenu();
if (!teacher.getMenuActive()) {
break;
}
} while (true);
}
else if (teacher.checkRoster(currentUser)) {
// Insert Student Menu Here...
cout << "Student Menu: \n";
}
else {
cin.clear();
cin.ignore(100,'\n');
cerr << "Invalid user name.\n";
}
} else {
cin.clear();
cin.ignore(100,'\n');
cerr << "Invalid user name.\n";
}
} while(keepRunning);
return 0;
}
\ No newline at end of file
......@@ -230,6 +230,16 @@ void Teacher::endProgram() {
exit(0);
}
// Checks the roster for a given student, and returns true if found.
bool Teacher::checkRoster(string student) {
for (int i = 0; i < roster.size(); i++) {
if (roster.at(i).getUserName() == student) {
return true;
}
}
return false;
}
// Accessors
const string Teacher::getUserName() {
return userName;
......
......@@ -28,6 +28,9 @@ class Teacher {
void adjustProgress(string studentUserNameIn, int level); // Changes a students level; includes error checking for student username
void endProgram(); // saves and ends program gracefully
/* Andrew - I added this function to search for a given student in the roster (for use in login stage) */
bool checkRoster(string student);
// Accessors
const string getUserName();
const string getExitCode();
......
......@@ -14,3 +14,4 @@ inghro | 2
umalno | 1
grifno | 1
levina | 4
Andrew | 500
......@@ -12,4 +12,6 @@ umalno 1
grifno 1
levina 4
Andrew 500
Sam 2
Jared 1
END_OF_FILE
\ 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