While loop in C++

Soldato
Joined
14 Apr 2004
Posts
11,888
Location
UK
Hey guys,

Making a One Arm Bandit Machine and the program is almost done (Or we assume so!) bar this section:

PHP:
void chooseOptions()
{
 if (usersOption == 'R' || usersOption ==  'r')
  displayRules();
 else if (usersOption == 'P' || usersOption ==  'p')
  playOneGame();
 else if (usersOption == 'B' || usersOption ==  'b')
  displayResults();
}

We're trying to achieve a main page that directs everything to sub menu's.

Been trying Trial and Error for a stupid amount of hours over the past 6 days and we're having no luck :(

Time is running out, have 4 hours till deadline :(

Here's an example:

etendedzw4.jpg


Would appreciate any help please!
 
int main ()
{

cout <<"\n";
cout <<"\n";
cout <<"\n";
cout << "----------AOB OPTIONS----------"<< '\n';
cout << "DISPLAY THE RULES: R"<< '\n';
cout << "PLAY ONE GAME: P"<< '\n';
cout << "DISPLAY BALANCE: B"<< '\n';
cout << "SHOW STATISTICS: S"<< '\n';
cout << "SET TESTING MODE: T"<< '\n';
cout << "QUIT PROGRAM: Q"<< '\n';
cout << "-----------------------------"<< '\n';
cout << "ENTER YOUR COMMAND (R, P, S, T or Q):"<< '\n';
cout << "-----------------------------"<< '\n';
cin >> usersOption;
cout << "-----------------------------"<< '\n';
cout <<"\n";
cout <<"\n";
chooseOptions();


return (0);

}
 
jamiemoles said:
Why don't you just pass usersOptions to chooseOptions() as an argument?

I tend to printf or cout variables just before I do tests on them to see what the compiler thinks the variables are before I test them. You'd be surprised how often you miss something daft.
Could you please elaborate of that? Especially the arguments?

Tommy - I am.
 
Jamiemoles- Tried that and messing around with it for almost an hour, still no luck.

LazyManc - In all honestly, time was an enemy against us, we had 4 other assignment prior to this!

Got 90 minutes or so left, this doesnt look good :(
 
jamiemoles said:
Right, cout the usersOption variable before entering the chooseOption function, then do it again as the first line of the chooseOption function.

What do you get?


Also what datatype have you defined usersOption as?
We get exactly the same problem and the usersOption is defined as int.
 
Thanks a lot guys but it seems we failed it cause our useroption was an Int as opposed to a char which was a silly mistake. That lost us 20%, hence we failed our first.

Absolutely gutted as I've been hitting some very good marks as of recent weeks :(

You live to learn eh?
 
Back
Top Bottom