// ***************************************************************************** // Author: Eddy Marinez // Implemenation file for Student class // Comments should explain everything // **************************************************************************** #include #include "Questions.h" #include "Student.h" #include 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; /* 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 { 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(choice == 'Y'){ //testing stage testingStage(); testing = true; break; }else if(choice == 'N'){ //reset values for count count=0; break; }else{ cout << "Invalid input." < 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--; }if(testOut==true){ //if right it increments the count and decrements the question var count++; question--; }if(count>=(question/2)){ cout << "Congratulations! you have passed." << endl; setLevel(++levelIn); break; }else{ cout << "Tough luck. try harder next time."; /* some code to loop it back to the practice section? */ } /* 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? */ } } // 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; }