![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Professional Programmer
|
You can write a method which shows the options and receives the input. Have all your if statements for the options and then just an else for anything else. Next you can just return a boolean. If everything went ok then return true and if they type in somethign else return false.
|
|
|
|
|
|
#12 |
|
Programmer
Join Date: May 2006
Posts: 39
Rep Power: 0
![]() |
yeah, thanks...
I was thinking of using arrays instead, because how I'm doing it currently means it will take a very long time. I have to ask if its oging to be afternoon or evening, which breaks it into two groups, then I have to ask which seat they want, from a choice of 3, then finally I have to ask if they wan't concession tickets. If I do it with arrays, I think I can forgo all the if's and elses, and in the end process it all in one go... though I don't know how I can control the input if I use arrays, for instance if the options are 1, 2 or x, I don't know how I can tell the user of the error and give them a second chance of doing it... If I'm headed down the wrong path with arrays, please tell me... |
|
|
|
|
|
#13 | ||
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,005
Rep Power: 5
![]() |
Quote:
You can use repeated conditional statements to test for validity, or (in certain cases, such as yours) build up a list of valid inputs (in an array, for example), and then iterate through the list, checking each time. Quote:
do
{
valid = false;
// prompt user for input here
// initialize 'userInput' variable with input from user
if(userInput == whateverItShouldBe)
valid = true;
} while(!valid);
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
||
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|