Question: Project requirements: For this project your team will write the card game-Joker, for which you will use a standard deck of 52 cards with one

Project requirements:

For this project your team will write the card game-Joker, for which you will use a standard deck of 52 cards with one Joker card added to it. There will be only 2 players, the computer (dealer) and one user/player. After the matching pairs are discarded, the hand with more cards will start first (choosing the card from the opponent). For example, after discarding the matching pairs, if a computers hand has 9 cards and the users hand has 6 cards, the computer will start first (choosing a card from the users hand) Play will continue with each player taking turns until one of the players is left with a Joker card in the hand. This player is the loser (Joker).

Joker card game

Implementing this final project without using linked lists results in 0 point for this project.

1) To simulate the deck of 53 cards, and each of the hands, your team MUST use a dynamic list of cards with the following struct type:

OR Each card consists of a suit [clubs (),spades (),hearts (), or diamonds ())

a face (1(Ace) 10, Jacks (J), Queens (Q), and Kings (K))

Each hand (computer or user) should be implemented using linked list. The card removed from the hand should be removed from its linked list.

2) Create a full deck of 53 cards that are in order. In other words, for each of the four suits, the cards should be in order from Ace (1) through King (13). Add one more for Joker card (assign such as 100 for suit and 100 for face or any values that your code can use to identify this Joker card)

Note: Your code must have a CreateDeck( ) function that creates a standard deck of 53 cards. At the demo time, you will be asked to print the deck that you create.

typedef struct card_s {

char suit;

typedef struct card_s {

} card;

int face;

struct card_s *listp;

} card;

char suit[10];

int face;

struct card_s *listp;

2

3) You must then shuffle the deck Note: Your code must have a ShuffleCard( ) function and should work with any number of cards, i.e. shuffling 53 cards, 20 cards or 5 cards. Make sure that it shuffles the deck thoroughly or the hand thoroughly. One idea for shuffling the cards:

(a) For each card in the deck (or hand), get a random number in the range of 0 to 52 (number of cards in the hand 1) to be used as the index of the element to swap that card with, i.e.

if deck[0] holds the Jack of clubs (J) and the random number generated was 24, and deck[24] holds the 9 of diamonds(9), then after the first swap, deck[0] would hold the

9 of diamonds (9), and deck[24] would hold the Jack of clubs (J ). You would then proceed to deck[1], find a random index of a card to swap with, and swap those cards, etc.

Johns hand: 9 of diamonds 7 of clubs 8 of diamonds King of clubs Jack of diamonds 10 of diamonds

//given that John was entered at the start of the game

7) The play will begin => The hand with more cards will start first. Your code should display number of cards that the computer/dealer has and ask a user which card number to choose, i.e.

I now have 7 cards: //a computer has 7 cards after discarding the pairs 1234567 Which one do you choose? Enter a number between 1 and 7: 1 // 1 is entered by a user

If the match occurs, display a message that the pair is removed and the users hand, i.e. 3

8)

9)

Removing a pair: King of clubs and the King of spades

Johns hand: Jack of diamonds 10 of diamonds 8 of diamonds 9 of diamonds 7 of clubs

Note: If you compare the above with the hand under item 7), you should see now that the King of clubs is gone from Johns hand and the cards are shuffled.

If the match does not occur, your code should shuffle the cards and display the cards.

After a player draws a card from the opponent's hand and places it into his/her hand (and discard the pair if a match occurs), whether the player is the computer or the user, the hand must be shuffled. This shuffling is necessary to keep the player from knowing where the Joker card is, if it has just been drawn from the opponent's hand.

At the end of the game, your code - announce the winner or loser (Joker); - ask whether a user wants to play a new game (or q or Q to quit)

Sample Code Execution: Red entered by a user

Note: You are encouraged to make your output look nicer than what is given below. However, your

code should display the same information.

It is VERY LIKELY that you will NOT get the exact same code execution shown below. This is used to show

you how the game should be played.

Enter your name: John

***---*** ***---*** ***---*** John, let's play Joker ***---*** ***---*** ***---***

John's hand has 26 cards J Q 5 4 3 5 9 J 6 8 9 6 A Q 6 2 5 7 2 J Q 10 K 4 Joker 9

***---***Hit Enter key to continue***---***

Dealer's hand: throw away pairs Remove pair:2 2 Remove pair:3 3 Remove pair:K K

Remove pair:8 8 Remove pair:A A Remove pair:10 10 Remove pair:4 4 Remove pair:7 7

I now have 11 cards ***---***Hit Enter key to continue***---***

John's hand: throw away pairs Remove pair:J J Remove pair:Q Q Remove pair:5 5

Remove pair:4 4 Remove pair:9 9 Remove pair:6 6 Remove pair:2 2

John, this is your hand: 3 8 A 6 5 7 J Q 10 K Joker 9

***---***Hit Enter key to continue***---*** you have more cards, you start

<= display number of cards that a computer has left

<= display the players hand after the cards are

distributed

<= I create my own pause() function that make

it easier for a user to follow the game.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!