Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are asked to write a program to simulate a simple card game. The only cards allowed in this game are: Jae}; Queen. King and

image text in transcribedimage text in transcribedimage text in transcribed
You are asked to write a program to simulate a simple card game. The only cards allowed in this game are: Jae}; Queen. King and Ace. These cards could be of any suits. Two players will play this game. and they decide how many rounds of this game they would like to play. The cards will be randomly "drawn" for them. In order to be able to pick these cards, we generate a random number in the range 1 through 4 inclusive. separately for both face and suit and separately for each player. We also implement the following pattern to be able to map random integers to our card specications. This mapping scheme MUST enforce the original established order of precedence when it comes to faces of these cards: 1 representing Jack 2 representing Queen 3 representing King and 4 representing Ace "We will have the similar ranking for the suits. We must acknowledge that in this case no suit will have higher value compared to another. and the numberng is just for the purpose of mapping integers to strings: 1 representing Clubs 2 representing Diamonds 3 representing Hearts and 4 representing Spades You MUST use switch statements for enforcing the above rules. You will designate variables for each player's card in terms of face and suit. and these variables can be randomly populated based the above rules and mapping scheme. Next comes the establishing of the rules of the game. Just like in real life card-game rules. the order of value in terms of face is: Area > King > Queen > Jack. Do you see that our numbering scheme is geared towards this pattern? In case the random number generator picked identical cards for the two players. you [MILST force another pick for the second player as the assumption is that the two players will draw cards from a single deck of cards where no duplicates can be found. Please note that we allow identical faces or identical suits but not both. 1When you make sure the players have valid cards drawn (randomly generated), then you implement your rules and keep track of the win or the draw status of the game on each round. The following outlines what this program needs to do in general: Prompt for the names of each player. Prompt them for the number of games they would like to play Set up a loop for that many rounds of game In the loop you must do the random number generation and determine the face and the suit of the random card based on a switzh statement. You need to make sure that the second player does not get an identical card to the rst player. This step resembles the validation process. if you get a duplicate you need to pick another random number for the second player. Need to check to see who has the winning card Keep a count of number of wins for each player. as well as the number of draws Announce the winner for each round And when the game ends. announce a complete report in terms of individual wins. total number of draws. and who is the ultimate winner of the game. In the next page, you will nd two sample runs of this game side by side for you to use as reference. Follow the format. the wordings and the style of the output so that you won't lose any points. Please note that the numbers specifying each round of the game match the counting form 1 pattern. 'We chose this as an attempt to have a user iendly messaging. I recommend that you use counting from zero in your program but just for the sake of the user adjust the counter values to everyday format of starting with 1. only for your output. Please enter the name of the first player: Adam Please enter the name of the first player: Ben Please enter the name of the second player: Eve Please enter the name of the second player: Jerry How many rounds of game would you like to play? 10 How many rounds of game would you like to play? 8 Round #1: Round #1: Adam draws Ace of Spades Ben draws Queen of Diamonds Eve draws King of Hearts Jerry draws Ace of Hearts Adam wins this round! Jerry wins this round! Round #2: Round #2: Adam draws Queen of Clubs Ben draws Ace of Hearts Eve draws Queen of Spades Jerry draws King of Diamonds Game is a draw! Ben wins this round! Round #3: Round #3: Adam draws King of Spades Ben draws King of Diamonds Eve draws Jack of Diamonds Jerry draws Jack of Diamonds Adam wins this round! Ben wins this round! Round #4: Round #4: Adam draws King of Clubs Ben draws Queen of Diamonds Eve draws King of Hearts Jerry draws Ace of Spades Game is a draw! Jerry wins this round! Round #5: Round #5: Adam draws Jack of Diamonds Ben draws Ace of Clubs Eve draws Queen of Hearts Jerry draws Ace of Spades Eve wins this round! Game is a draw! Round #6: Round #6: Adam draws King of Clubs Ben draws Queen of Clubs Eve draws Ace of Hearts Jerry draws Queen of Hearts Eve wins this round! Game is a draw! Round #7: Round #7: Adam draws Ace of Hearts Ben draws King of Diamonds Eve draws King of Clubs Jerry draws King of Clubs Adam wins this round! Game is a draw! Round #8: Round #8: Adam draws Jack of Spades Ben draws Jack of Spades Eve draws Ace of Spades Jerry draws Queen of Diamonds Eve wins this round! Jerry wins this round! Round #9: Adam draws King of Hearts Here is the report of the game: Eve draws Jack of Clubs Number of wins for Ben: 2. Adam wins this round! Number of wins for Jerry: 3. Number of draws: 3. Round #10: Jerry wins the game with total win of 3. Adam draws Jack of Diamonds Eve draws Ace of Spades Eve wins this round! Here is the report of the game: Number of wins for Adam: 4. Number of wins for Eve: 4. Number of draws: 2. The game is a draw

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions