diff --git a/Student.h b/Student.h new file mode 100644 index 0000000000000000000000000000000000000000..72a5fec26a2f1c2efbaa4c829c3d3227dc78810d --- /dev/null +++ b/Student.h @@ -0,0 +1,45 @@ +// *********************************************************************** +// NOTE: I had to put this together to get the Teacher class working. +// Feel free to use this file or not, but please note that the +// Teacher.h/.cpp files depend on these exact functions and +// function names, so please use these names in the final class. +// +// Thanks! -Andrew +// *********************************************************************** + +#include + +class Student { + public: + //Default constructor for only a username + Student(string userNameIn) { + userName = userNameIn; + } + + // Default constructor for a username and level + Student(string userNameIn, int levelIn) { + userName = userNameIn; + level = levelIn; + } + + // Accessors + int getLevel() { + return level; + } + string getUserName() { + return userName; + } + + // Mutators + void setLevel(int levelIn) { + level = levelIn; + } + + void setUserName(string userNameIn) { + userName = userNameIn; + } + + private: + string userName; + int level = 1; +}; diff --git a/Teacher.cpp b/Teacher.cpp index 78a6a0b5e707f8659890f8d3dc4685e7167abe0a..05e84d1fb82a4e1271fa162d182cdb176e9614e9 100644 --- a/Teacher.cpp +++ b/Teacher.cpp @@ -1,6 +1,8 @@ #include "Teacher.h" #include #include +#include +#include ofstream fout; ifstream fin; @@ -22,15 +24,29 @@ void Teacher::displayMenu() { } void Teacher::displayProgress() { - cout << "------STUDENT GRADEBOOK------\n"; - cout << "Student\t\tCurrent Level\n"; - for (int i = 0; i < roster.size(); i++) { - cout << roster.at(i).getUserName() << "\t\t" << roster.at(i).getLevel() << endl; + cout << userName << "'s Class Progress Report" << endl << endl; + cout.width(10); + cout << left << "Student" << "|\t" << "Current Level\n"; + cout << "-----------------------------\n"; + for (int i = 0; i < roster.size(); i++) { + cout.width(10); + cout << left << roster.at(i).getUserName() << "|\t" << roster.at(i).getLevel() << endl; } } void Teacher::exportProgress() { + fout.open("classProgress.txt"); + fout << userName << "'s Class Progress Report" << endl << endl; + fout.width(10); + fout << left << "Student" << "|\t" << "Current Level\n"; + fout << "-------------------------\n"; + for (int i = 0; i < roster.size(); i++) { + fout.width(10); + fout << left << roster.at(i).getUserName() << "|\t" << roster.at(i).getLevel() << endl; + } + + fout.close(); } void Teacher::saveProgress() { @@ -103,7 +119,7 @@ void Teacher::adjustProgress(string studentUserNameIn, int level) { } void Teacher::endProgram() { - + saveProgress(); } // Accessors diff --git a/Teacher_Driver.cpp b/Teacher_Driver.cpp index a12fe34f6f583461a13f8f8e04889bd8b715bf6f..d0c379433b6a5b91b3dd0acfaf0526cfe34986cc 100644 --- a/Teacher_Driver.cpp +++ b/Teacher_Driver.cpp @@ -21,7 +21,7 @@ int main() { cout << "The test teachers name is " << testTeacher.getUserName() << ".\n\n"; - cout << "Display Menu:\n"; + // cout << "Display Menu:\n"; //testTeacher.displayMenu(); @@ -45,7 +45,7 @@ int main() { // testTeacher.adjustProgress("Andrew",5); testTeacher.displayProgress(); - + testTeacher.exportProgress(); // testTeacher.saveProgress(); return 0; diff --git a/classProgress.txt b/classProgress.txt new file mode 100644 index 0000000000000000000000000000000000000000..ce18dbf8aea851d7522aaecc23535f2fcf2bee3b --- /dev/null +++ b/classProgress.txt @@ -0,0 +1,16 @@ +Andrew's Class Progress Report + +Student | Current Level +------------------------- +sextsa | 1 +tituja | 3 +sacalu | 1 +allsna | 3 +sextja | 1 +mamatt | 2 +culvxa | 3 +duerwe | 1 +inghro | 2 +umalno | 1 +grifno | 1 +levina | 4 diff --git a/classRoster.txt b/classRoster.txt index ef3863634d941d36e62c7a0c7ecd6038c9198cba..922a8687e28c4c48773dc5344d58edb077eba142 100644 --- a/classRoster.txt +++ b/classRoster.txt @@ -1,6 +1,14 @@ Andrew Quit -Andrew 1 -Asher 3 -Joe 1 -John 3 +sextsa 1 +tituja 3 +sacalu 1 +allsna 3 +sextja 1 +mamatt 2 +culvxa 3 +duerwe 1 +inghro 2 +umalno 1 +grifno 1 +levina 4 END_OF_FILE \ No newline at end of file