in reply to Pseduo code planning

Do you really want to exit the program if they get the card wrong? Sounds like you'll have a lot of very short games to me. A do/while loop is close to a natural fit for this, since you want to execute the shuffle once first before testing, although I think it'll make more sense to move the user input and testing part from the while condition and into the do block.

do { shuffle and display card; read input; } while (input correct); exit(0);

Of course, since the program as described could be written in so few lines utilizing a shuffling module (e.g., Algorithm::Numerical::Shuffle since it came up earlier today), you might as well use a label and a goto :^)


"The dead do not recognize context" -- Kai, Lexx

Replies are listed 'Best First'.
Re: Re: Pseudo code planning
by kutsu (Priest) on Jun 08, 2003 at 02:16 UTC

    This is a very popular game in japan, and yes if the answer is wrong they lose, if right they are asked if the want to continue, usually this means a bigger payoff.

    Might consider adding:

    if ($guess was right) { continue(); } else { exit; } sub continue() { ask user to enter y or n read in answer chomp answer lowercase input #or uppercase I just like lower default input to n unless it is y or n #or y if you were a real hu +ssler return answer }

    Yes my pseudo code has code in it, just the way I code :). Didn't read merlyn post before posting, so this was not meant as an opinion. My opinion on that is merely that this post asked for pseudo code so I gave pseudo code. Thought this was both because I really don't know who to do this, and I'm just weird.

    Update: changed last statment

    "Pain is weakness leaving the body, I find myself in pain everyday" -me