Cp5639 - implementing the card guessing game - you are to


IMPLEMENTING THE CARD GUESSING GAME

Task:

You are to implement (code in Python) a computer game as outlined in the following description. Use what you have learned in class, including functions, selection, repetition and lists. You should use any feedback that you received from Assignment 1 to improve your program flow.

NB: The game is slightly different than the original one. Please read the description carefully and note the changes. The following functionality items must be added to your program and weren't in the original planning assessment:
- Game loop so that the player can play more than one game; a game no longer has 10 rounds
- Betting system - amounts in multiples of 5, balance of $0 forces quit
- Error handling for incorrect user input
- Appropriate code comments (each function should have a comment describing its purpose)
- Display overall amount won or lost on exit
- Make use of constants for variables with values that do not change

Program Features:

You are to design a simple guessing game, played by one player against the computer.
When the program begins it will ask the user for their name, then welcome them to the Guessing Game. The game will then begin, displaying the player's current balance (which starts at $100). The player will be asked how much they want to bet, which must be a whole number no less than 1, multiple of 5 and no more than their balance.

Once their bet has been entered the game will randomly generate two numbers, one for the player and one for the computer (they can be equal). These numbers are to be whole numbers between 1 and 13 (representing cards: Ace, 2 -10, Jack, Queen, King).
The player will then be told the value of their card as both a number (if the value is between 2 and

10) and the name of the card (1 is an Ace, 11 is a Jack, 12 is a Queen, and 13 is a King). The player will then choose whether they think the computer's card will be higher or lower, by entering H or L. Upper and lower case must be accepted, but any other input will result in an error and being asked again. Once the player has chosen then the computer's card will be announced to the player.

If the player was correct they get double their bet back (e.g. started with 100, bet 10 (balance is 90), win 20 (balance is 110). If the player was wrong they lost their bet (e.g. started with 100, bet 10 (balance is 90)), and if the two cards are equal then it's a tie (e.g. started with 100, bet 10 (balance is 90), get 10 back (balance is 100)) and the next round starts.

Each game follows the same pattern:
- Display balance
- Take the bet
- Reveal player's card
- Get player's guess
- Reveal computer's card

- Reveal winning/losing message
- Update balance

After each round the player can choose to continue, or quit. If the player's balance hits zero then the game ends, as if they had chosen to quit.

Once the game ends a farewell message will be displayed, noting the final balance and whether or not the player won (or lost) money overall.

Implementation:
- Python file:
You are to divide your solution into functions, following the principles shown in class. These may involve one for each menu option (other than Quit) as well as functions for parts of the program (e.g. calculating the current player balance could be implemented as a function).

- Planning document:
You also need to provide an updated version of your previous planning document showing an algorithm in pseudocode for each function, being sure to clearly indicate input and output variables for each. This should be based on your submission for Assignment One, with appropriate changes being made for new functionality.

You may show your assignment to your tutor during practical time to get comments or suggestions. It is important to note that you can only get help from staff in practical time after your prac work is finished.

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Cp5639 - implementing the card guessing game - you are to
Reference No:- TGS02621406

Expected delivery within 24 Hours