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

All files working properly

parent 4d18081b
......@@ -14,13 +14,70 @@ Teacher::Teacher(string userNameIn) {
}
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 << "2. Export Class Progress" << endl;
cout << "3. Enroll Students" << endl;
cout << "4. Adjust Student Progress" << endl;
cout << "5. Change Username" << 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() {
......@@ -35,7 +92,7 @@ void Teacher::displayProgress() {
}
void Teacher::exportProgress() {
fout.open("classProgress.txt");
fout.open(progressFileName);
fout << userName << "'s Class Progress Report" << endl << endl;
fout.width(10);
......@@ -50,19 +107,21 @@ void Teacher::exportProgress() {
}
void Teacher::saveProgress() {
fout.open("classRoster.txt");
fout.open(rosterFileName);
fout << userName << " " << exitCode << endl;
for (int i = 0; i < roster.size(); i++) {
fout << roster.at(i).getUserName() << " " << roster.at(i).getLevel() << endl;
}
fout << "END_OF_FILE";
fout.close();
}
void Teacher::importProgress() {
string parseName;
int parseLevel;
fin.open("classRoster.txt");
fin.open(rosterFileName);
fin >> userName >> exitCode;
......@@ -131,6 +190,10 @@ const string Teacher::getExitCode() {
return exitCode;
}
const bool Teacher::getMenuActive() {
return teacherMenuActive;
}
// Mutators
void Teacher::setExitCode(string exitCodeIn) {
exitCode = exitCodeIn;
......
#include "Student.h"
#include <vector>
#include <string>
using namespace std;
class Student {
public:
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;
};
#ifndef TEACHER_H
#define TEACHER_H
class Teacher {
public:
......@@ -52,14 +25,21 @@ class Teacher {
// Accessors
const string getUserName();
const string getExitCode();
const bool getMenuActive();
// Mutators
void setExitCode(string exitCodeIn);
void setUserName(string userNameIn);
private:
bool teacherMenuActive = 1;
string userName;
string exitCode = "Quit";
vector<Student> roster;
string rosterFileName = "classRoster.txt"; // Used for use by program as import/export
string progressFileName = "classProgress.txt"; // Used for teacher
};
#endif //TEACHER_H
\ No newline at end of file
......@@ -9,44 +9,21 @@
using namespace std;
int main() {
string teacherUserName;
cout << "First we will test the constructor: \nInput a username: ";
// cin >> teacherUserName;
Teacher testTeacher;
testTeacher.importProgress();
cout << "The test teachers name is " << testTeacher.getUserName() << ".\n\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);
cout << "The test teachers name is " << testTeacher.getUserName() << ".\n";
testTeacher.displayProgress();
testTeacher.exportProgress();
// testTeacher.saveProgress();
do {
testTeacher.displayMenu();
if (!testTeacher.getMenuActive()) {
break;
}
} while (true);
return 0;
}
\ No newline at end of file
......@@ -11,4 +11,5 @@ inghro 2
umalno 1
grifno 1
levina 4
Andrew 500
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