Commit 6492841b authored by Andrew Binder's avatar Andrew Binder
Browse files

Added Student.h, updating Teacher class for more file I/O

parent adbf6362
// ***********************************************************************
// 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 <string>
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;
};
#include "Teacher.h" #include "Teacher.h"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <chrono>
#include <ctime>
ofstream fout; ofstream fout;
ifstream fin; ifstream fin;
...@@ -22,15 +24,29 @@ void Teacher::displayMenu() { ...@@ -22,15 +24,29 @@ void Teacher::displayMenu() {
} }
void Teacher::displayProgress() { void Teacher::displayProgress() {
cout << "------STUDENT GRADEBOOK------\n"; cout << userName << "'s Class Progress Report" << endl << endl;
cout << "Student\t\tCurrent Level\n"; cout.width(10);
cout << left << "Student" << "|\t" << "Current Level\n";
cout << "-----------------------------\n";
for (int i = 0; i < roster.size(); i++) { for (int i = 0; i < roster.size(); i++) {
cout << roster.at(i).getUserName() << "\t\t" << roster.at(i).getLevel() << endl; cout.width(10);
cout << left << roster.at(i).getUserName() << "|\t" << roster.at(i).getLevel() << endl;
} }
} }
void Teacher::exportProgress() { 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() { void Teacher::saveProgress() {
...@@ -103,7 +119,7 @@ void Teacher::adjustProgress(string studentUserNameIn, int level) { ...@@ -103,7 +119,7 @@ void Teacher::adjustProgress(string studentUserNameIn, int level) {
} }
void Teacher::endProgram() { void Teacher::endProgram() {
saveProgress();
} }
// Accessors // Accessors
......
...@@ -21,7 +21,7 @@ int main() { ...@@ -21,7 +21,7 @@ int main() {
cout << "The test teachers name is " << testTeacher.getUserName() << ".\n\n"; cout << "The test teachers name is " << testTeacher.getUserName() << ".\n\n";
cout << "Display Menu:\n"; // cout << "Display Menu:\n";
//testTeacher.displayMenu(); //testTeacher.displayMenu();
...@@ -45,7 +45,7 @@ int main() { ...@@ -45,7 +45,7 @@ int main() {
// testTeacher.adjustProgress("Andrew",5); // testTeacher.adjustProgress("Andrew",5);
testTeacher.displayProgress(); testTeacher.displayProgress();
testTeacher.exportProgress();
// testTeacher.saveProgress(); // testTeacher.saveProgress();
return 0; return 0;
......
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
Andrew Quit Andrew Quit
Andrew 1 sextsa 1
Asher 3 tituja 3
Joe 1 sacalu 1
John 3 allsna 3
sextja 1
mamatt 2
culvxa 3
duerwe 1
inghro 2
umalno 1
grifno 1
levina 4
END_OF_FILE END_OF_FILE
\ No newline at end of file
Supports Markdown
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