•Describe the symptoms of your problem carefully and clearly.
Once I input something, nothing happens, and still asks for another input.
•Describe the environment in which it occurs (machine, OS, application, whatever).
CLion
•Describe the research you did to try and understand the problem before you asked the question.
Google, this forum, other forums. It's hard to search for an unknown problem.
•Describe the diagnostic steps you took to try and pin down the problem yourself before you asked the question.
Switched my input from a char, to a string. Tried to store the input in main().
This is a homework problem, so I am asking very nicely to please, please, please don't just tell/show me where the problem is. I would appreciate very much, any wisdom on how to pinpoint a problem, and any hints or tricks for future developing.
Also, this is not complete. I just want to get over this hurdle before continuing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
#include <iostream>
#include <string>
using namespace std;
void printMenu(void);
string getUserInput(void);
int handleUserInput(string);
void printMachineStatus(int, int, int, int);
int storeLucky(void);
int storeCamel(void);
int storeGaul(void);
int storePall(void);
int main() {
printMenu();
getUserInput();
handleUserInput(getUserInput());
return 0;
}
void printMenu(void) {
cout << "s - report the machine status" << endl
<< "d - drop in a quarter" << endl
<< "1 - pull the 1st knob" << endl
<< "2 - pull the 2nd knob" << endl
<< "3 - pull the 3rd knob" << endl
<< "4 - pull the 4th knob" << endl
<< "r - restock the machine" << endl
<< "q - quit" << endl;
}
string getUserInput(void){
string Input;
cin >> Input;
return Input;
}
int handleUserInput(string){
if (getUserInput() == "s") {
printMachineStatus(storeLucky(), storeCamel(), storeGaul(), storePall());
cout << "s" << endl;
}
else if (getUserInput() == "d") {
//drop in quarter
cout << "d" << endl;
}
else if (getUserInput() == "1") {
//pull1Knob
cout << "1" << endl;
}
else if (getUserInput() == "2") {
//pull2Knob
cout << "2" << endl;
}
else if (getUserInput() == "3") {
//pull3Knob
cout << "3" << endl;
}
else if (getUserInput() == "4") {
//pull4Knob
cout << "4" << endl;
}
else if (getUserInput() == "r") {
//restock machine
cout << "r" << endl;
}
else if (getUserInput() == "q"){
cout << "So long!" << endl;
return 0;
}
else {
cout << "I do not understand." << endl;
return 0;
}
return 0;
}
void printMachineStatus(int, int, int, int){
cout << "1: " << storeLucky() << " packs of Lucky Strikes" << endl
<< "2: " << storeCamel() << " packs of Camels" << endl
<< "3: " << storeGaul() << " packs of Gauloises" << endl
<< "4: " << storePall() << " packs of Pall Malls" << endl;
}
int storeLucky(void){
int packs = 5;
return packs;
}
int storeCamel(void){
int packs = 7;
return packs;
}
int storeGaul(void){
int packs = 1;
return packs;
}
int storePall(void){
int packs = 6;
return packs;
|