Write a C program for the card game old main...Instructions as follows...Background Information:There  is a popular children's card game known as Old Maid. The game is for two or moreplayers. You...

Write a C program for the card game old main...Instructions as follows...Background Information:There  is a popular children's card game known as Old Maid. The game is for two or moreplayers. You can buy a special deck to play this game but you can also use a standard deck of 52 playingcards with a Joker card added to make it a deck of 53 cards.- The dealer deals one card at a time to each player proceeding clockwise until all the cards aredealt. Usually some players will have more cards than others. The cards of one player are calleda player’s hand.- The players then look at their cards and “discard” all their pairs (cards with the same face value(1 – 10) or cards with the same Face (Jacks, Queens, and Kings)).Examples of pairs would be:The 9 of diamonds (♦) and the 9 of spades (♠)The Jack of clubs (♣) and the Jack of hearts (♥)The Ace (1) of clubs (♣) and the Ace (1) of spades (♠)2- After all matching pairs are discarded, the dealer begins by allowing the player on his/her left tochoose one of his/her cards. The player selecting the card cannot see the card since he/she isonly shown the backs of the cards. That player will take a card from the dealer and add it tohis/her hand. If that card makes a pair, the player can discard the pair. That is the end of thatplayer's turn.- Next that player offers his/her cards to the player on his/her left and the play continues (Note:the player is allowed to shuffle his/her hand before offering it to the player on his/her left).- This process of taking a card and discarding a pair (if the match occurs) continues until theplayer has no card left on his/her hand (get rid of all cards). Eventually all except one player willhave no card. The player who is left holding a Joker card loses the game.Background information taken from http://en.wikipedia.org/wiki/Old_maid_(card_game). Note: ourJoker card game is a variant of the Old-maid card game.Project requirements:For this project your team will write the card game-Joker, for which you will use a standard deckof 52 cards with one Joker card added to it.There will be only 2 players, the computer (dealer) and one user/player. After the matchingpairs are discarded, the hand with more cards will start first (choosing the card from the opponent). Forexample, after discarding the matching pairs, if a computer’s hand has 9 cards and the user’s hand has 6cards, the computer will start first (choosing a card from the user’s hand)Play will continue with each player taking turns until one of the players is left with a Joker cardin the hand. This player is the loser (Joker).Joker card gameImplementing 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 ofcards with the following struct type: typedef struct card_s { char suit; int face; struct card_s *listp;} card;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 thehand 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, thecards should be in order from Ace (1) through King (13).Add one more for Joker card (use 100 for suit and 100 for face)Note: Your code must have a CreateDeck( ) function that creates a standard deck of 53 cards,that could be used for any card playing game.At the demo time, you will be asked to print the deck that you create.33) You must then shuffle the deck, using the following algorithm:(a) For each card in the deck, get a random number in the range of 0 to 52 to be used as theindex 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, anddeck[24] holds the 9 of diamonds(9♦), then after the first swap, deck[0] would hold the9 of diamonds (9♦), and deck[24] would hold the Jack of clubs (J ♣). You would thenproceed to deck[1], find a random index of a card to swap with, and swap those cards,etc.(b) Repeat step a) at least 100 times.Note: Your code must have a ShuffleCard( ) function using the algorithm explained above andshould work with any size deck of cards, i.e. shuffling 53 cards, 20 cards or 5 cards.(c) You must seed the random number generator with a call to time() with srand(). [see sec2.22 Random numbers in your Zyante book] At the demo time, you will be asked to print the deck after the shuffle is done.4) After shuffling the deck, you must deal the cards by giving one card to the user/player, followedby one card to the computer, followed by one card to the user, etc. until all of the cards havebeen dealt. At the demo time, you will be asked to print the computer’s hand and the user’s hand5) Next your program should remove all pairs from each of the players' hands and identify thosepairs as the cards are being removed.Every time the pair is removed, your code should display it, i.e.Removing a pair: 6 of clubs and 6 of diamonds6) After the pairs are removed from both computer’s hand and the user’ hand, the user’s handshould be displayed, i.e.John’s hand: //given that “John” was entered at the start of the game9 of diamonds7 of clubs8 of diamondsKing of clubsJack of diamonds10 of diamonds7) 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 whichcard number to choose, i.e.I now have 7 cards: //a computer has 7 cards after discarding the pairs 1 2 3 4 5 6 7Which one do you choose?Enter a number between 1 and 7: 1 // 1 is entered by a userIf the match occurs, display a message that the pair is removed and the user’s hand, i.e.Removing a pair: King of clubs and the King of spades4John’s hand:Jack of diamonds10 of diamonds8 of diamonds9 of diamonds7 of clubsNote: If you compare the above with the hand under item 7), you should see now that theKing of clubs is gone from John’s hand and the cards are shuffled.If the match does not occur, your code should shuffle the cards and display the cards.8) After a player draws a card from the opponent's hand and places it into his/her hand (anddiscard the pair if a match occurs), whether the player is the computer or the user, the handmust be shuffled. This shuffling is necessary to keep the player from knowing where the Jokercard is, if it has just been drawn from the opponent's hand.9) 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)See sample code executions on pages 6 – 14 (there are 3 games played in the sample code)Optional Features for extra credit:1) Graphics: Add graphics to your game.(+1 pt) If you can print using ♣, ♠, ♥, ♦(+2 pts) If you can make the card for each card look like (at least)---------- ----------|9♥ | |K♣ || | | || | | || 9♥ | | K♣|---------- ---------2) (+ 2 pts) Game Variations: Only discard the pair with the same point and the same-colored suit,i.e. clubs (♣) and spades (♠) or diamonds (♦) and hearts (♥)). Examples of pairs now would be:The 9 of clubs (♣) and the 9 of spades (♠)The Ace (1) of diamonds (♦) and the Ace of hearts (♥)The Jack of clubs (♣) and the Jack of spades (♠)3) (5 pts) Game statistics. Keep statistics on players and the computer with number of wins andlosses- Create a text file that keeps a user’s name, number of wins and number of losses.[each line consists of user’s name number of wins number of losses]You should start with computer, your name, your team member name with some number ofwins and losses in the file.5- At the beginning, ask a user whether he/she wants to create a new user or continue with anexisting one.- Once a game is finished, after announcing whether a user wins or loses,(+ 1 pts) display his/her name and number of wins and number of losses. If the user is anexisting one, the current win or loss should be added into his/her record before display.(+1 pts) if your code can access a text file to write ONLY the stats of the new player(meaning that it overwrites what already in the text file)(+1 pts) if your code can update the stats of the existing players in the text file.If the user is an existing one, the updated statistics should be kept in the text file(written back into the text file).(+2 pts) if your code can access a text file to write/add the stats of the new playerafter the existing players’ stats in the text file -> adding a new row into the file.


May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here