Play Card Game Create a Java program that will simulate a card

Added on - 22 Sep 2019

Trusted by 2+ million users,
1000+ happy students everyday
Showing pages 1 to 2 of 4 pages
Play Card Game Create a Java program that will simulate a card game in which four players will play thegame with a deck of cards. Assume the deck of cards represents a typical playing deck of cardscontaining 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 eachface. Table 1 and Table 2 show a mapping for the suits and card faces, respectively. You should use theseinteger code values, NOT the string names, in your simulation program to represent a suit and a cardface rank. For example, the code for the card ‘Five of Spade’ should be two integer values as 3 5, wherethe 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 orderfor the cards in the deck.Step 2 (Distribute): Distribute the cards among four players in 13 rounds, starting from the first card inthe shuffled deck of cards, i.e., one player will get 1 card in each round from the randomly shuffled deckof card. For example, in the 1st round of distribution, Player-1 will receive the 1st card, Player-2 willreceive the 2nd card, Player-3 will receive the 3rd card, and Player-4 will receive the 4th card. In the 2ndround of distribution, Player-1 will receive the 5th card, Player-2 will receive the 6th card, Player-3 willreceive the 7th card, and Player-4 will receive the 8th card, and so on. Thus, at the end of thedistribution, 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 1stround 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 soon.Step 4 (Find deal winner): The winner of a deal will be selected based on the face ranks of the four cardsplayed by four players. The player who plays the card with the highest rank among all four cards in adeal 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
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 thecard 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 suitrank of cards (the higher suit value will get higher rank). For example, if the status of a round of deal isas follows: Deal number 01: 0 3, 2 7, 0 7, 1 4Then, the winner of this deal is Player-2 (Player-2 and Player-3 played the highest ranked cards (i.e., 7) inthe 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 highestnumber of deals among all 13 deals. Input of your simulation: Typically, your program should not requireany input from user. The inputs are two fixed code tables, which can be hard coded using suitable datastructures (e.g., Array or ArrayList) into your code. However, you may want to create an interactivemenu to allow user to play multiple times, which is optional.Output
Desklib Logo
You are reading a preview
Upload your documents to download or

Become a Desklib member to get access