Start Main( ) Get name of player Get cash (starting cash amout) Set more = "yes" Start Loop Set betAmount = 0; Start Loop Get betAmount If( betAmount > cash ) Display "You do not have enough cash for that bet amount." Display "Cash: " & cash End If While( betAmount > cash ), continue looping Display "Press Enter to draw a card." Generate a random number from 2 to 14 and place in player variable Call DisplayCard( player ) Display "Press Enter to see the dealer’s card." Create a random number between 2 and 14 and place in dealer variable Call DisplayCard( dealer ) Call Evaluate( player, dealer ) that returns a boolean (true if player wins) If player wins then Display name & ", you win!" Increase cash by the betAmount Otherwise Display name & ", you lose" Decrease cash by the betAmount End If If cash > 0 then Display "You have " & cash & " cash in hand." Get more with prompt "Play again? (yes/no): " Otherwise Display "You are out of cash." Set more = "no" End If While more = "yes", continue looping Display "Thanks for playing." Stop Start DisplayCard( card as integer ) If card = 14 then Display "Ace" Otherwise if card = 13 then Display "King" Otherwise if card = 12 then Display "Queen" Otherwise if card = 11 then Display "Jack" Otherwise if card >= 2 AND card <= 10 then Display card Otherwise Display "Error: " & card & "is not valid." End If Stop Start Evaluate( player, dealer ) If player > dealer then Return true Otherwise if dealer > player then Return false Otherwise Display "Tie. We go to WAR!" Display "Press Enter to draw a card." Generate a random number between 2 and 14 and place in player variable Call DisplayCard( player ) Display "Press Enter to see the dealer’s card." Create a random number between 2 and 14 and place in dealer variable Call DisplayCard( dealer ) Return result of Evaluate( player, dealer ) –recursion will continue until someone wins End If Stop
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)