Sure, in pseudocode (or wishfulthinking code) it's a piece cake:
The devil is in the details :-).print_greeting(); reset_score(); OUTER: while ( 1 ) { my $current_question = ask_next_question(); my $attempts = 0; while ( $attempts++ < $MAX_ATTEMPTS ) { my $answer = get_answer(); last OUTER if $answer eq 'q'; last if check_answer( $current_question, $answer ); print_sorry_try_again(); } if ($attempts < $MAX_ATTEMPTS ) { print_congratulations(); update_score( 1 ); } else { explain_correct_answer( $current_question ); update_score( 0 ); } } print_score(); print_good_bye();
the lowliest monk
In reply to Re: setup of a small perl game
by tlm
in thread setup of a small perl game
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |