-------------------------------------------------------------------------------- PROGRAM ACEY DUCEY -------------------------------------------------------------------------------- LANGUAGES TO IMPLEMENT IN -------------------------------------------------------------------------------- # LANGUAGE IDE -- --------- ---------------------------------------------- 01 Ada GNAT Studio 02 BASIC GW-BASIC 03 C\C++ C-Free 04 C# Visual Studio 2019 05 COBOL OpenCobolIDE 06 Java Eclipse 07 Lua ZeroBrane Studio 08 Pascal Turbo Pascal 09 Perl Notepad++ -> Command Line 10 PowerShell Notepad++ -> Windows PowerShell 11 Python Idle 12 VB .NET Visual Studio 2019 13 Haskell Emacs 14 Assembly GUI Turbo Assembler -------------------------------------------------------------------------------- VARIABLES -------------------------------------------------------------------------------- Running(BOOLEAN) for main outer loop GameOver(BOOLEAN) for inner loop Wallet(INTEGER) holds player's money Cards(ARRAY OF INTEGERS) holding the three dealt cards. -------------------------------------------------------------------------------- METHODS/FUNCTIONS -------------------------------------------------------------------------------- AskQuestion -------------------------------------------------------------------------------- ACCEPT : prompt(STRING) RETURN : STRING LOGIC : display the prompt and accept input. all input is uppercased, then return the input. do not allow empty string. if the string is empty display PLEASE ANSWER THE QUESTION. -------------------------------------------------------------------------------- GetIntInput -------------------------------------------------------------------------------- ACCEPT : prompt(STRING) RETURN : INTEGER LOGIC : display the prompt and accept input. verify that the response is an INTEGER using IsAnInt method and if it is not, display YOU DID NOT ENTER AN INTEGER. and ask again. otherwise return the response. -------------------------------------------------------------------------------- IsAnInt -------------------------------------------------------------------------------- ACCEPT : input(STRING) RETURN : BOOLEAN LOGIC : determine if the input is an INTEGER or not and return BOOLEAN -------------------------------------------------------------------------------- AskForBet -------------------------------------------------------------------------------- ACCEPT : NONE RETURN : INTEGER LOGIC : ask player WHAT IS YOUR BET? and accept input. check to see that the input is an INTEGER and is non-negative. if it fails, tell the player PLEASE BET A NON-NEGATIVE AMOUNT. check to see if the bet is greater than the wallet. if it is, tell the player SORRY MY FRIEND, BUT YOU BET TOO MUCH. then display YOU HAVE ONLY (Wallet) DOLLARS TO BET and ask again. return the INTEGER response. -------------------------------------------------------------------------------- AskToPlayAgain -------------------------------------------------------------------------------- ACCEPT : NONE RETURN : BOOLEAN LOGIC : ask the player DO YOU WANT TO PLAY AGAIN? and get a response, the response is compared against uppercased YES or Y and NO or N. if the response is anything else, display PLEASE ANSWER "YES" OR "NO" and ask again. if the response is YES or Y or NO or N then return a BOOLEAN value that represents that response. Use AskQuestion for this. -------------------------------------------------------------------------------- AskToSeeTheRules -------------------------------------------------------------------------------- ACCEPT : NONE RETURN : BOOLEAN LOGIC : ask DO YOU WANT TO SEE THE RULES? and accept a response. if the response is YES or Y then return TRUE otherwise return FALSE. Use AskQuestion method for this. -------------------------------------------------------------------------------- DisplayCard -------------------------------------------------------------------------------- ACCEPT : card(INTEGER) RETURN : NONE LOGIC : display either the numeric value of the card if it is under 11 or JACK for 11, QUEEN for 12, KING for 13, and ACE for 14 -------------------------------------------------------------------------------- DisplayRules -------------------------------------------------------------------------------- ACCEPT : NONE RETURN : NONE LOGIC : display the rules as ACEY DUCEY IS PLAYED IN THE FOLLOWING MANNER: THE DEALER (COMPUTER) DEALS TWO CARDS FACE UP YOU HAVE THE OPTION TO BET OR NOT BET DEPENDING ON WHETHER OR NOT YOU FEEL THE NEXT CARD WILL HAVE A VALUE BETWEEN THE FIRST TWO. IF YOU DO NOT WANT TO BET, INPUT A 0 (ZERO). -------------------------------------------------------------------------------- GenerateRandomNumber -------------------------------------------------------------------------------- ACCEPT : minimum(INTEGER) maximum(INTEGER) show(BOOLEAN) RETURN : INTEGER LOGIC : generate a random INTEGER between minimum and maximum, show determines if it displays the value generated or not, finally return the generated value. -------------------------------------------------------------------------------- SelectCard -------------------------------------------------------------------------------- ACCEPT : NONE RETURN : INTEGER LOGIC : randomly select a card between 2 and 14. verify that it has not been selected for any of the values in Cards. if it has, try again, otherwise call DisplayCard and return the value. -------------------------------------------------------------------------------- Main Logic -------------------------------------------------------------------------------- display *** ACEY DUCEY : [LANGUAGE] *** set Running to TRUE if AskToSeeTheRules returns TRUE call DisplayRules loop while Running initialize Wallet to 100 set GameOver = FALSE loop while GameOver is FALSE display YOU NOW HAVE [Wallet] DOLLARS. Cards[1] = SelectCard Cards[2] = SelectCard Bet = AskForBet if Bet > 0 Cards[3] = SelectCard if Cards[3] is between Cards[1] and Cards[2] display YOU WIN!!! increase Wallet by Bet else display SORRY, YOU LOSE. decrease Wallet by Bet set Cards[1-3] to 0 to clear them out if Wallet < 1 display SORRY FRIEND, YOU ARE BROKE. set GameOver = TRUE else Bet = 0 set GameOver = TRUE do loop logic display *** GAME OVER *** if AskToPlayAgain returns FALSE, then set Running = FALSE do loop logic display OK, HOPE YOU HAD FUN. display THANKS FOR PLAYING! --------------------------------------------------------------------------------