Commit dc73ebb6 authored by Jared Sexton's avatar Jared Sexton

Debugging Student

parent 727083ca
......@@ -44,16 +44,19 @@ void Student::displayMenu(){
if (cin){
switch(choice){
case 1: // Practice
practice();
break;
case 2: // Log Out
cout << "Goodbye." << endl;
break;
break; /* Can you have something here that will cause the program to exit the menu when they choose logout?
This can be done with a boolean return type for this function (returns true until they choose to logout, then it returns false)
Or with a separate function like Andrew did in Teacher (you can check his code for a template).
The idea is that as much of the process of each menu is contained within the menu function, (ecapsulation). */
default:
cout << "Invalid choice.\n";
break;
}
}else {
} else {
cin.clear();
cin.ignore(100,'\n');
cout << "Invalid choice.\n";
......@@ -64,15 +67,15 @@ void Student::displayMenu(){
//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 practice(){
void Student::practice(){
int count =0;
char choice;
bool gotitGood, testing;
do{
gotitGood=Questions::mainQuestionAsk(getLevel());
gotitGood=questionAsk.mainQuestionAsk(getLevel());
if(gotitGood==true){
couter++;
}if(counter>=3){
count++;
}if(count>=3){
do{
cout << "Would you like to test out? (Y)es/(N)o ";
cin >> choice;
......@@ -81,7 +84,7 @@ void practice(){
testing = true;
break;
}else if(choice == 'N'){
counter=0;
count=0;
break;
}else{
cout << "Invalid input." <<endl;
......@@ -95,19 +98,21 @@ void practice(){
//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 testingStage(){
void Student::testingStage(){
int count =0;
int levelIn = getLevel();
char choice;
bool testOut, finish;
while{
testOut=Questions::mainQuestionAsk(getLevel());
while(true){
testOut=questionAsk.mainQuestionAsk(getLevel());
if(testOut==true){
couter++;
}if(counter>=5){
count++;
}if(count>=5){
cout << "Congratulations! you have passed." << endl;
setLevel(levelIn)++;
}
setLevel(++levelIn);
break;
} /* Note (from Jared): Can we add something so that this will only ask a certain number of questions (say, 10?)
and if they don't get enough f them right by then, it will tell them they need to practice more? */
}
}
......
......@@ -9,7 +9,6 @@
#include <string>
#include "Questions.h"
#include "Student.cpp"
using namespace std;
......@@ -48,6 +47,7 @@ class Student {
private:
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
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