Commit 1fa47ce4 authored by Andrew Binder's avatar Andrew Binder

Merge branch 'master' of gitlab.cs.wallawalla.edu:sextja/cptr142_group_project

parents e755f593 d16470e7
/* ============================================================================
Main Function
g++ -std=c++11 MAIN.cpp Questions.cpp Teacher.cpp -o MAIN.cpp.o && ./MAIN.cpp.o
Student.cpp (add in when it exists)
g++ -std=c++11 MAIN.cpp Questions.cpp Teacher.cpp Student.cpp -o MAIN.cpp.o && ./MAIN.cpp.o
============================================================================
*/
......@@ -14,8 +13,9 @@ using namespace std;
int main() {
Teacher teacher;
// Bring in current class data from the file
teacher.importProgress();
string currentUser;
bool keepRunning = true;
do {
......@@ -23,6 +23,7 @@ int main() {
cin >> currentUser;
if (cin) {
if(currentUser == teacher.getExitCode()) {
keepRunning = false;
}
else if (currentUser == teacher.getUserName()) {
......@@ -35,14 +36,22 @@ int main() {
}
else if (teacher.checkRoster(currentUser) >= 0) {
int currentUserIndex = teacher.checkRoster(currentUser);
// Make new student object and copy all their info from teacher vector
Student currentStudent;
currentStudent = teacher.getStudent(currentUserIndex);
// Current user (Student object) : currentStudent
// Current user (Student object) is currentStudent
do {
currentStudent.displayMenu();
if (!currentStudent.getMenuActive()) {
break;
}
} while (true);
// save any changes back into teacher vector
teacher.setStudent(currentStudent);
// save any changes to the file.
teacher.saveProgress();
}
else {
cin.clear();
......
......@@ -145,6 +145,7 @@ bool Questions::addSubQuestion(int level) {
return false;
}
bool Questions::wordQuestion(int level) {
cout << "Question type not configured.";
return false;
......
......@@ -23,6 +23,12 @@ class Questions {
// Asks a question, returns true if the kid was right, false if they were wrong.
bool wordQuestion(int level);
// Accessor
int getMaxLevel() { return maxLevel; }
private:
int maxLevel = 10;
};
#endif //QUESTIONS_H
\ No newline at end of file
// *****************************************************************************
// Author: Eddy Marinez
// Implemenation file for Student class
// Comments should explain everything
// ****************************************************************************
#include <string>
#include "Questions.h"
#include "Student.h"
#include <iostream>
using namespace std;
// Default Constructor
// Input: none
// Output: object with Student username of NULL
Student::Student(){
userName = "NULL";
}
// Default Constructor
// Input: username of student
// Output: object with student username of NULL
Student::Student(string userNameIn) {
userName = userNameIn;
}
// Default Constructor
// Input: username and level
// Output: object with student username of NULL
Student::Student(string userNameIn, int levelIn) {
userName = userNameIn;
level = levelIn;
}
// Runs student Menu
// Input: A user's menu selection
// Output: Changes are made based on users input
void Student::displayMenu(){
int choice;
cout << endl << "Student Menu." << endl << endl;
cout << "1. Practice Level #"<< getLevel() << endl;
cout << "2. Log Out" << endl;
cin >> choice;
if (cin){
switch(choice){
case 1: // Practice
practice();
break;
case 2: // Log Out
cout << "Goodbye." << endl;
studentMenuActive =0;
break;
default:
cout << "Invalid choice.\n";
break;
}
} else {
cin.clear();
cin.ignore(100,'\n');
cout << "Invalid choice.\n";
}
}
//menu options
//Practice: referenced with the questiones.h file, ask questions until they ge 3-5 right.
//Practice: present the option to enter testing mode.
//Practice: if yes. enter testing mode as bellow, if no. continue practicing for another 3-5 questions.
void Student::practice(){
int count =0;
char choice;
bool gotitGood, testing;
do{
gotitGood=questionAsk.mainQuestionAsk(getLevel()); //set equal to a bool expression to check if true, also helps keep track
if(gotitGood==true){
count++;
}if(count>=3){
do{
cout << "Would you like to test out? (Y)es/(N)o ";
cin >> choice;
if(cin) {
if(choice == 'Y'){ //testing stage
testingStage();
testing = true;
break;
}else if(choice == 'N'){ //reset values for count
count=0;
break;
}else{
cin.clear();
cin.ignore(100,'\n');
cerr << "Invalid choice." <<endl;
continue;
}
} else {
cin.clear();
cin.ignore(100,'\n');
cerr << "Invalid choice.\n";
}
}while(true);
}
}while(testing == false);
}
//Testing Stage: same difficulty questions, and they will be given a set number of them (10, 15, 20)
//Testing Stage: congratulate if they get enough right. increment dificulty level.
//Testing Stage: exit testing mode and go back to menu.
void Student::testingStage(){
int count =0;
int question=10;
int levelIn = getLevel();
char choice;
bool testOut, finish;
while(question > 1){
testOut=questionAsk.mainQuestionAsk(getLevel()); //set equal to a bool expression to check if true, also helps keep track
if(testOut==false){ //decrements question var if wrong
question--;
}else{ //if right it increments the count and decrements the question var
count++;
question--;
}
}
if(count>=7){
cout << "Congratulations! you have passed." << endl;
setLevel(++levelIn);
}else{
cout << "Tough luck. try harder next time.";
}
}
// Accessors
int Student::getLevel() {
return level;
}
string Student::getUserName() {
return userName;
}
// Mutators
void Student::setLevel(int levelIn) {
level = levelIn;
}
void Student::setUserName(string userNameIn) {
userName = userNameIn;
}
const bool Student::getMenuActive() {
return studentMenuActive;
}
\ No newline at end of file
......@@ -8,6 +8,7 @@
// ***********************************************************************
#include <string>
#include "Questions.h"
using namespace std;
......@@ -16,52 +17,39 @@ using namespace std;
class Student {
public:
// Default constructor
Student() {
userName = "NoName";
}
//Default constructor for only a username
Student();
Student(string userNameIn) {
userName = userNameIn;
}
Student(string userNameIn);
// Default constructor for a username and level
Student(string userNameIn, int levelIn) {
userName = userNameIn;
level = levelIn;
}
// Copy constructor
Student(const Student& studentIn) {
userName = studentIn.userName;
level = studentIn.level;
}
Student(string userNameIn, int levelIn);
// Accessors
int getLevel() {
return level;
}
string getUserName() {
return userName;
}
int getLevel();
string getUserName();
const bool getMenuActive();
//Student functions.
void displayMenu();
void testingStage();
void displayMenu(); //Display menu; show the current level, option to practice or log out.
//menu options
void practice(); //Practice: referenced with the questiones.h file, ask questions until they ge 3-5 right.
//Practice: present the option to enter testing mode.
//Practice: if yes. enter testing mode as bellow, if no. continue practicing for another 3-5 questions.
void testingStage(); //Testing Stage: same difficulty questions, and they will be given a set number of them (10, 15, 20)
//Testing Stage: congratulate if they get enough right. increment dificulty level.
//Testing Stage: exit testing mode and go back to menu.
// Mutators
void setLevel(int levelIn) {
level = levelIn;
}
void setLevel(int levelIn);
void setUserName(string userNameIn) {
userName = userNameIn;
}
void setUserName(string userNameIn);
private:
bool studentMenuActive = 1;
string userName;
int level = 1;
Questions questionAsk;
};
#endif //STUDENT_H
\ No newline at end of file
// *****************************************************************************
// AUTHOR: Jared Sexton
// This file is a test drive for the Student.h/cpp classes.
//
// Test Drive compilation instructions:
// g++ -std=c++11 Student_Driver.cpp Student.cpp Questions.cpp -o Student_Driver.cpp.o && ./Student_Driver.cpp.o
// *****************************************************************************
#include <string>
#include <iostream>
#include "Student.h"
using namespace std;
int main() {
Student testStudent("James", 3);
cout << "The test student's name is " << testStudent.getUserName() << ".\n";
do {
testStudent.displayMenu();
} while (true);
return 0;
}
\ No newline at end of file
......@@ -40,8 +40,6 @@ class Teacher {
void setUserName(string userNameIn);
void setStudent(Student studentIn); // I think it's safe to say that studentIn will be a student in the vector; so the function will find where the student goes in the vector by itself
// vector<Student> roster;
private:
bool teacherMenuActive = 1;
string userName;
......
......@@ -67,3 +67,11 @@ _Feedback_
Grade: __M__ 3/7/2018
_Feedback_
* Included complete UML diagrams __complete__
* Included a procedural flow diagram __complete__
* Listed anticipated challenges __complete__
* Detailed project management plan __complete__
Grade: __E__ 3/11/2018
......@@ -14,4 +14,7 @@ inghro | 2
umalno | 1
grifno | 1
levina | 4
Andrew | 500
Andrew | 10
Sam | 2
Jared | 4
bindan | 10
......@@ -11,8 +11,8 @@ inghro 2
umalno 1
grifno 1
levina 4
Andrew 500
Andrew 10
Sam 2
Jared 1
bindan 43
Jared 4
bindan 10
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