Commit 4f63ceb4 authored by Andrew Binder's avatar Andrew Binder

All files working properly

parent 4d18081b
...@@ -14,13 +14,70 @@ Teacher::Teacher(string userNameIn) { ...@@ -14,13 +14,70 @@ Teacher::Teacher(string userNameIn) {
} }
void Teacher::displayMenu() { void Teacher::displayMenu() {
cout << "------Teacher Menu------" << endl; teacherMenuActive = true;
int menu, levelIn;
string stringIn;
cout << endl << "Teacher Menu" << endl << endl;
cout << "1. Display Class Progress" << endl; cout << "1. Display Class Progress" << endl;
cout << "2. Export Class Progress" << endl; cout << "2. Export Class Progress" << endl;
cout << "3. Enroll Students" << endl; cout << "3. Enroll Students" << endl;
cout << "4. Adjust Student Progress" << endl; cout << "4. Adjust Student Progress" << endl;
cout << "5. Change Username" << endl; cout << "5. Change Username" << endl;
cout << "6. Change Exit Code" << endl; cout << "6. Change Exit Code" << endl;
cout << "7. Log Out" << endl;
cout << endl << "Enter Selection: ";
cin >> menu;
if (cin) {
switch(menu) {
case 1:
displayProgress();
break;
case 2:
exportProgress();
cout << "Gradebook exported succesfully." << endl;
break;
case 3:
{
cout << "Please enter a username (no spaces): ";
cin >> stringIn;
Student studentIn(stringIn);
enrollStudent(studentIn);
break;
}
case 4:
cout << "Please enter the student's username followed by a level: ";
cin >> stringIn >> levelIn;
adjustProgress(stringIn, levelIn);
break;
case 5:
cout << "Your username is currently " << userName << "." << endl;
cout << "Please input a new username: ";
cin >> stringIn;
setUserName(stringIn);
break;
case 6:
cout << "The exit code is currently " << exitCode << "." << endl;
cout << "Please input a new exit code: ";
cin >> stringIn;
setExitCode(stringIn);
break;
case 7:
saveProgress();
cout << "Goodbye." << endl;
teacherMenuActive = 0;
// exit(0);
break;
default:
cout << "Invalid choice.\n";
break;
}
} else {
cin.clear();
cin.ignore(100,'\n');
cout << "Invalid choice.\n";
}
} }
void Teacher::displayProgress() { void Teacher::displayProgress() {
...@@ -35,7 +92,7 @@ void Teacher::displayProgress() { ...@@ -35,7 +92,7 @@ void Teacher::displayProgress() {
} }
void Teacher::exportProgress() { void Teacher::exportProgress() {
fout.open("classProgress.txt"); fout.open(progressFileName);
fout << userName << "'s Class Progress Report" << endl << endl; fout << userName << "'s Class Progress Report" << endl << endl;
fout.width(10); fout.width(10);
...@@ -50,19 +107,21 @@ void Teacher::exportProgress() { ...@@ -50,19 +107,21 @@ void Teacher::exportProgress() {
} }
void Teacher::saveProgress() { void Teacher::saveProgress() {
fout.open("classRoster.txt"); fout.open(rosterFileName);
fout << userName << " " << exitCode << endl; fout << userName << " " << exitCode << endl;
for (int i = 0; i < roster.size(); i++) { for (int i = 0; i < roster.size(); i++) {
fout << roster.at(i).getUserName() << " " << roster.at(i).getLevel() << endl; fout << roster.at(i).getUserName() << " " << roster.at(i).getLevel() << endl;
} }
fout << "END_OF_FILE"; fout << "END_OF_FILE";
fout.close(); fout.close();
} }
void Teacher::importProgress() { void Teacher::importProgress() {
string parseName; string parseName;
int parseLevel; int parseLevel;
fin.open("classRoster.txt"); fin.open(rosterFileName);
fin >> userName >> exitCode; fin >> userName >> exitCode;
...@@ -131,6 +190,10 @@ const string Teacher::getExitCode() { ...@@ -131,6 +190,10 @@ const string Teacher::getExitCode() {
return exitCode; return exitCode;
} }
const bool Teacher::getMenuActive() {
return teacherMenuActive;
}
// Mutators // Mutators
void Teacher::setExitCode(string exitCodeIn) { void Teacher::setExitCode(string exitCodeIn) {
exitCode = exitCodeIn; exitCode = exitCodeIn;
......
#include "Student.h"
#include <vector> #include <vector>
#include <string> #include <string>
using namespace std; using namespace std;
class Student { #ifndef TEACHER_H
public: #define TEACHER_H
Student(string userNameIn) {
userName = userNameIn;
}
Student(string userNameIn, int levelIn) {
userName = userNameIn;
level = levelIn;
}
int getLevel() {
return level;
}
string getUserName() {
return userName;
}
void setLevel(int levelIn) {
level = levelIn;
}
void setUserName(string userNameIn) {
userName = userNameIn;
}
private:
string userName;
int level = 1;
};
class Teacher { class Teacher {
public: public:
...@@ -52,14 +25,21 @@ class Teacher { ...@@ -52,14 +25,21 @@ class Teacher {
// Accessors // Accessors
const string getUserName(); const string getUserName();
const string getExitCode(); const string getExitCode();
const bool getMenuActive();
// Mutators // Mutators
void setExitCode(string exitCodeIn); void setExitCode(string exitCodeIn);
void setUserName(string userNameIn); void setUserName(string userNameIn);
private: private:
bool teacherMenuActive = 1;
string userName; string userName;
string exitCode = "Quit"; string exitCode = "Quit";
vector<Student> roster; vector<Student> roster;
}; string rosterFileName = "classRoster.txt"; // Used for use by program as import/export
\ No newline at end of file string progressFileName = "classProgress.txt"; // Used for teacher
};
#endif //TEACHER_H
\ No newline at end of file
...@@ -9,44 +9,21 @@ ...@@ -9,44 +9,21 @@
using namespace std; using namespace std;
int main() { int main() {
string teacherUserName; string teacherUserName;
cout << "First we will test the constructor: \nInput a username: ";
// cin >> teacherUserName;
Teacher testTeacher; Teacher testTeacher;
testTeacher.importProgress(); testTeacher.importProgress();
cout << "The test teachers name is " << testTeacher.getUserName() << ".\n\n"; cout << "The test teachers name is " << testTeacher.getUserName() << ".\n";
// cout << "Display Menu:\n";
//testTeacher.displayMenu();
// cout << "Now, we will enroll some students.\nEnter three students names: ";
// for (int i = 0; i < 3; i++) {
// string studentNameIn;
// cin >> studentNameIn;
// Student studentIn(studentNameIn);
// 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(); do {
testTeacher.exportProgress(); testTeacher.displayMenu();
// testTeacher.saveProgress(); if (!testTeacher.getMenuActive()) {
break;
}
} while (true);
return 0; return 0;
} }
\ No newline at end of file
...@@ -11,4 +11,5 @@ inghro 2 ...@@ -11,4 +11,5 @@ inghro 2
umalno 1 umalno 1
grifno 1 grifno 1
levina 4 levina 4
Andrew 500
END_OF_FILE 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