From bce03cab130ae29976848e7ad38f2c62373b04bb Mon Sep 17 00:00:00 2001 From: "Andrew.Binder" Date: Mon, 5 Mar 2018 22:34:40 +0000 Subject: [PATCH] Updating Teacher Class --- Teacher.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++++ Teacher.h | 27 +++++++++++++++++++------- Teacher_Driver.cpp | 37 ++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 Teacher_Driver.cpp diff --git a/Teacher.cpp b/Teacher.cpp index 5a0b30d..5744117 100644 --- a/Teacher.cpp +++ b/Teacher.cpp @@ -1,5 +1,52 @@ #include "Teacher.h" +#include Teacher::Teacher(string userNameIn) { userName = userNameIn; +} + +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; + } +} + +bool Teacher::exportProgress() { + +} + +bool Teacher::enrollStudent(Student studentIn) { + roster.push_back(studentIn); +} + +bool Teacher::adjustProgress(Student studentIn, int level) { + +} + +void Teacher::endProgram() { + +} + +// Accessors +const string Teacher::getUserName() { + return userName; +} + +const string Teacher::getExitCode() { + return exitCode; +} + +// Mutators +bool Teacher::setExitCode(string exitCodeIn) { + exitCode = exitCodeIn; +} + +bool Teacher::setUserName(string userNameIn) { + userName = userNameIn; } \ No newline at end of file diff --git a/Teacher.h b/Teacher.h index 3b2ea03..da7ae65 100644 --- a/Teacher.h +++ b/Teacher.h @@ -5,6 +5,10 @@ using namespace std; class Student { public: + Student(string userNameIn) { + userName = userNameIn; + } + int getLevel() { return level; } @@ -12,17 +16,20 @@ class Student { return userName; } + void setLevel(int levelIn) { + level = levelIn; + } + + void setUserName(string userNameIn) { + userName = userNameIn; + } + private: string userName; int level = 1; }; class Teacher { - private: - string userName; - string exitCode; - //vector roster; - public: Teacher(string userNameIn); // Default constructor @@ -30,8 +37,8 @@ class Teacher { void displayMenu(); void displayProgress(); // Opens menu, teacher get get all (gradebook style) or a student bool exportProgress(); // outputProgress() in UML - // bool enrollStudent(Student studentIn); - // bool adjustProgress(Student studentIn, int level); + bool enrollStudent(Student studentIn); + bool adjustProgress(Student studentIn, int level); void endProgram(); // Accessors @@ -41,4 +48,10 @@ class Teacher { // Mutators bool setExitCode(string exitCodeIn); bool setUserName(string userNameIn); + + private: + string userName; + string exitCode; + vector roster; + }; \ No newline at end of file diff --git a/Teacher_Driver.cpp b/Teacher_Driver.cpp new file mode 100644 index 0000000..ca2ebc6 --- /dev/null +++ b/Teacher_Driver.cpp @@ -0,0 +1,37 @@ +// *************************************** +// Test Drive compilation instructions: +// g++ -std=c++11 Teacher_Driver.cpp Teacher.cpp -o Teacher_Driver.cpp.o + +#include +#include +#include "Teacher.h" + +using namespace std; + +int main() { + + string teacherUserName; + + cout << "First we will test the constructor: \nInput a username: "; + cin >> teacherUserName; + + Teacher testTeacher(teacherUserName); + cout << "The test teachers name is " << testTeacher.getUserName() << ".\n\n"; + + 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); + } + + cout << "\nNow we will test the displayProgress() function.\n"; + testTeacher.displayProgress(); + + + return 0; +} \ No newline at end of file -- GitLab