Commit ec6b777f authored by Andrew Binder's avatar Andrew Binder

Modifying file I/O handling and modified Questions.h to use const static for maxLevel

parent b52edf74
......@@ -28,7 +28,7 @@ class Questions {
int getMaxLevel() { return maxLevel; }
private:
int maxLevel = 10;
const static int maxLevel = 10;
};
#endif //QUESTIONS_H
\ No newline at end of file
......@@ -137,8 +137,6 @@ void Teacher::saveProgress() {
for (int i = 0; i < roster.size(); i++) {
fout << roster.at(i).getUserName() << " " << roster.at(i).getLevel() << endl;
}
// Marks the end of the file for importer
fout << "END_OF_FILE";
fout.close();
}
......@@ -156,17 +154,14 @@ void Teacher::importProgress() {
while (true) {
// Checks next line to see if there's a student
fin >> parseName;
if (parseName == "END_OF_FILE") {
// If there isn't a student, end import
break;
fin >> parseName >> parseLevel;
// If there is a student, create a student and add it to the student vector
if (fin) {
Student studentIn(parseName, parseLevel);
roster.push_back(studentIn);
} else {
// If there is student, read its level
fin >> parseLevel;
break;
}
// If there is a student, create a student and add it to the studen vector
Student studentIn(parseName, parseLevel);
roster.push_back(studentIn);
}
fin.close();
......@@ -197,10 +192,9 @@ void Teacher::enrollStudent(string studentIn) {
// Output: Changed student within the roster vector and success or not
void Teacher::adjustProgress(string studentUserNameIn, int level) {
int studentNumber = checkRoster(studentUserNameIn); // Check if student exists/Get student position in vector
Questions question;
Questions *maxLevel = new Questions;
if (level > maxLevel->getMaxLevel()) {
if (level > question.getMaxLevel()) {
cout << "Error: Level too high!" << endl;
} else {
// If the username exists, change the level and output success to console
......@@ -214,7 +208,6 @@ void Teacher::adjustProgress(string studentUserNameIn, int level) {
}
}
delete maxLevel;
}
// Saves and ends program safely and gracefully
......
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