Java-Based Card Game Simulation: Rules, Implementation, and Output

Verified

Added on  2019/09/22

|4
|887
|741
Practical Assignment
AI Summary
This assignment requires the development of a Java program to simulate a card game involving four players and a standard 52-card deck. The program must implement core game mechanics, including shuffling the deck, distributing cards to each player over 13 rounds, and simulating the play of the game. The program should adhere to specific rules for determining the winner of each deal based on card ranks and suits, with tiebreakers based on suit values. The input involves hard-coded tables for suits and card faces, and the output should clearly display the cards played by each player in each round, along with the winner of each deal. The ultimate goal is to determine the overall winner of the game based on the number of deals won. The program should simulate the game's logic, from shuffling the deck to determining the final winner, and provide a clear output of the game's progress.
Document Page
Play Card Game Create a Java program that will simulate a card game in which four players will play the
game with a deck of cards. Assume the deck of cards represents a typical playing deck of cards
containing 52 cards that has a face rank (e.g., “Ace”, “Deuce”, “Three”…………”Ten”, “Jack”, “Queen”,
“King”) and a suit (e.g., “Spades”, “Hearts”, “Diamonds”, “Clubs”). Each suit has 13 cards one for each
face. Table 1 and Table 2 show a mapping for the suits and card faces, respectively. You should use these
integer code values, NOT the string names, in your simulation program to represent a suit and a card
face rank. For example, the code for the card ‘Five of Spade’ should be two integer values as 3 5, where
the first value indicates the suite rank (i.e., Spade) and the second value indicates the face rank.
Similarly, ‘Ace of Clubs’ = 0 14, ‘Jack of Hearts = 2 11, and so on.
Rules to play: Step 1 (Shuffle): Shuffle all cards (52 cards in the deck of cards) to obtain a random order
for the cards in the deck.
Step 2 (Distribute): Distribute the cards among four players in 13 rounds, starting from the first card in
the shuffled deck of cards, i.e., one player will get 1 card in each round from the randomly shuffled deck
of card. For example, in the 1st round of distribution, Player-1 will receive the 1st card, Player-2 will
receive the 2nd card, Player-3 will receive the 3rd card, and Player-4 will receive the 4th card. In the 2nd
round of distribution, Player-1 will receive the 5th card, Player-2 will receive the 6th card, Player-3 will
receive the 7th card, and Player-4 will receive the 8th card, and so on. Thus, at the end of the
distribution, each player will receive 13 random cards in total.
Step 3 (Play): There will be 13 rounds of deal in the play. For each round, each player will deal (i.e., play)
one card. Each player will play a card in the order he/she received the cards. For example, for the 1st
round of deal, all players will play the cards that they received in the 1st round of distribution. Similarly,
in the 2nd round of deal, they will play the cards they received in the 2nd round of distribution, and so
on.
Step 4 (Find deal winner): The winner of a deal will be selected based on the face ranks of the four cards
played by four players. The player who plays the card with the highest rank among all four cards in a
deal is the winner of that deal. For example, assume the status of the 1st round deal (Deal number 01)
of a typical play is as follows. Deal number 01: 0 3, 2 7, 0 9, 1 4
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
It displays the cards played by all players in sequence of players’ order (i.e., Player-1 has played card 0 3,
which is 3 of Clubs, Player-2 has played card 2 7, Player-3 has played 0 9, and Player-4 has played the
card 1 4. The winner of this deal is Player-3 (who played the card with the highest face rank, i.e., 9).
If there is a tie on face ranks (among more than one cards), the winner will be selected based on the suit
rank of cards (the higher suit value will get higher rank). For example, if the status of a round of deal is
as follows: Deal number 01: 0 3, 2 7, 0 7, 1 4
Then, the winner of this deal is Player-2 (Player-2 and Player-3 played the highest ranked cards (i.e., 7) in
the deal, but between them, Player-2 played the card from a higher suit (i.e., 2)).
Step 5 (Select the Winner): The overall winner of the game is/are the player(s) who win(s) the highest
number of deals among all 13 deals. Input of your simulation: Typically, your program should not require
any input from user. The inputs are two fixed code tables, which can be hard coded using suitable data
structures (e.g., Array or ArrayList) into your code. However, you may want to create an interactive
menu to allow user to play multiple times, which is optional.
Output
Document Page
Document Page
chevron_up_icon
1 out of 4
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]