Java Card Game Simulation: A 4-Player Card Game Program

Verified

Added on  2019/09/22

|4
|887
|741
Project
AI Summary
This assignment requires creating a Java program that simulates a card game where four players play with a deck of cards. The game consists of five steps: shuffling the deck, distributing the cards among the players in 13 rounds, playing one card per round, finding the winner of each deal based on the face rank and suit of the played cards, and selecting the overall winner of the game.

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
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

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
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
1 out of 4
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]