Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The card game 99 (Ninety Nine) is a simple turn-based multiplayer game, where each player takes a turn playing a card from their hand, and

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

The card game 99 (Ninety Nine) is a simple turn-based multiplayer game, where each player takes a turn playing a card from their hand, and adds the value of the card to the running total. The player who causes the total to go over 99 loses the round. . Create a program that simulates a round of 99: Players are dealt 3 cards. The point total starts at zero and each card adds its face value in points (example: a 5 is worth five points, a face card is worth 10 points) except for certain cards that have special values or meanings: A4 reverses play and does not change the total number of points) A 9 is a pass (and does not change the total number of points) A 10 subtracts 10 points from the total A King takes the point total to 99 (or keeps it 99 if the total is already 99) An Ace adds either 1 or 11 points, announced by the player who plays it After each card is played, the player announces the new total to the table and draws a replacement card. Each player must play a card without sending the total number of points higher than 99. If a player cannot play a card that keeps the total at or less than 99, that player loses a token and the round ends. 1. Develop a generic CircularDoublyLinkedList Use the circularly and doubly linked list classes from our notes as a basis. Start with the DLL and think of how it can work circularly. Sentinels are not required, only a reference to the last node Node will have references to the next and previous nodes addBetween and remove () private utilities will be used, all adding and removing will work like doubly A boolean field, isForward, represents the direction of rotation Your CircularDoublelinkedList class will support the following public methods: size() Returns the number of elements in the list. isEmpty Returns true if the list is empty, and false otherwise. first() Returns (but does not remove) the first element in the list. last() Returns (but does not remove) the last element in the list. addFirst (e) Adds a new element to the front of the list. addLast (e) Adds a new element to the end of the list. removeFirst() Removes and returns the first element of the list. removeLast (0) Removes and returns the last element of the list. rotate() Advances to the next element in the list based on direction reverse() Changes the direction 2. Create the following classes: 1 GameSim 1 is played with Deck 1 1 involves consists of 1 Player Card plays a) Card contains 2 enum types: Suit: CLUBS, SPADES, HEARTS, DIAMONDS RANK: numbers TWO to TEN, JACK, QUEEN, KING, ACE b) Deck stores an ArrayList (from Java API) of Cards Upon initialization a deck of 52 cards should be built. - create and add all 52 cards in a deck (i.e. each rank of each suit). Include a shuffle () method that shuffles the cards Include a method that removes a card from the top (front) of the deck and returns the card instance C) Player stores the player name and an ArrayList of Cards as their hand. Include a method to play a card (removes and returns a given card from the hand). d) GameSim class that runs the game *Note - most of the work will be done here. As1PartA_Driver should have minimal code: e.g. declare/create a GameSim instance, add players, initiate game play. Fields: a CircularDoublyLinkedList of players - a Deck of cards the running total of the round any other field required to manage the game Upon instantiation of a game, set up the list of players (use 4 players for your demo/sample data), create the deck, shuffle and deal 3 cards to each player. Begin the game with the first player in the list. Each player will have their turn when positioned at the head of the list. Notes: Use enhanced enums to set the value for a face card. Mark special cards through this value. - If the player plays an ACE, play 11 unless it will cause them to lose the round. When faced with possibly going over 99, the player should play a card that prevents them from losing. Otherwise any card can be played. Note in the sample output below, the first card in the hand is played. To format output, include a String field display and override the enum's toString(). Use unicode values \u2663, \u2660, \u2665, \u2666 for clubs, spades, hearts and diamonds respectively. Sample output: Let's play 99!!! Players: Simba, Nala, Timon, Pumbaa (Nala's hand: Ad, 20, 50) Nala plays A. The total is 1 (Timon's hand: 44, 4., 5.) Timon plays 44 Game reverses direction (Nala's hand: 2, 5, K) Nala plays 2 The total is 3 (Simba's hand: 6, 0+, K) Simba plays 6 The total is 9 (Pumbaa's hand: 104, 9, 8) Pumbaa plays 104 The total is -1 (Timon's hand: 4., 5., 9) Timon plays 4. Game reverses direction (Pumbaa's hand: 9., 8., Pumbaa plays 9 Simba skips a turn (Nala's hand: 5, K, 59) Nala plays 5 The total is 4 (Timon's hand: 5., 90, 34) Timon plays 5. The total is 9 (Pumbaa's hand: 8., QV, 6.) Pumbaa plays 8. The total is 17 The card game 99 (Ninety Nine) is a simple turn-based multiplayer game, where each player takes a turn playing a card from their hand, and adds the value of the card to the running total. The player who causes the total to go over 99 loses the round. . Create a program that simulates a round of 99: Players are dealt 3 cards. The point total starts at zero and each card adds its face value in points (example: a 5 is worth five points, a face card is worth 10 points) except for certain cards that have special values or meanings: A4 reverses play and does not change the total number of points) A 9 is a pass (and does not change the total number of points) A 10 subtracts 10 points from the total A King takes the point total to 99 (or keeps it 99 if the total is already 99) An Ace adds either 1 or 11 points, announced by the player who plays it After each card is played, the player announces the new total to the table and draws a replacement card. Each player must play a card without sending the total number of points higher than 99. If a player cannot play a card that keeps the total at or less than 99, that player loses a token and the round ends. 1. Develop a generic CircularDoublyLinkedList Use the circularly and doubly linked list classes from our notes as a basis. Start with the DLL and think of how it can work circularly. Sentinels are not required, only a reference to the last node Node will have references to the next and previous nodes addBetween and remove () private utilities will be used, all adding and removing will work like doubly A boolean field, isForward, represents the direction of rotation Your CircularDoublelinkedList class will support the following public methods: size() Returns the number of elements in the list. isEmpty Returns true if the list is empty, and false otherwise. first() Returns (but does not remove) the first element in the list. last() Returns (but does not remove) the last element in the list. addFirst (e) Adds a new element to the front of the list. addLast (e) Adds a new element to the end of the list. removeFirst() Removes and returns the first element of the list. removeLast (0) Removes and returns the last element of the list. rotate() Advances to the next element in the list based on direction reverse() Changes the direction 2. Create the following classes: 1 GameSim 1 is played with Deck 1 1 involves consists of 1 Player Card plays a) Card contains 2 enum types: Suit: CLUBS, SPADES, HEARTS, DIAMONDS RANK: numbers TWO to TEN, JACK, QUEEN, KING, ACE b) Deck stores an ArrayList (from Java API) of Cards Upon initialization a deck of 52 cards should be built. - create and add all 52 cards in a deck (i.e. each rank of each suit). Include a shuffle () method that shuffles the cards Include a method that removes a card from the top (front) of the deck and returns the card instance C) Player stores the player name and an ArrayList of Cards as their hand. Include a method to play a card (removes and returns a given card from the hand). d) GameSim class that runs the game *Note - most of the work will be done here. As1PartA_Driver should have minimal code: e.g. declare/create a GameSim instance, add players, initiate game play. Fields: a CircularDoublyLinkedList of players - a Deck of cards the running total of the round any other field required to manage the game Upon instantiation of a game, set up the list of players (use 4 players for your demo/sample data), create the deck, shuffle and deal 3 cards to each player. Begin the game with the first player in the list. Each player will have their turn when positioned at the head of the list. Notes: Use enhanced enums to set the value for a face card. Mark special cards through this value. - If the player plays an ACE, play 11 unless it will cause them to lose the round. When faced with possibly going over 99, the player should play a card that prevents them from losing. Otherwise any card can be played. Note in the sample output below, the first card in the hand is played. To format output, include a String field display and override the enum's toString(). Use unicode values \u2663, \u2660, \u2665, \u2666 for clubs, spades, hearts and diamonds respectively. Sample output: Let's play 99!!! Players: Simba, Nala, Timon, Pumbaa (Nala's hand: Ad, 20, 50) Nala plays A. The total is 1 (Timon's hand: 44, 4., 5.) Timon plays 44 Game reverses direction (Nala's hand: 2, 5, K) Nala plays 2 The total is 3 (Simba's hand: 6, 0+, K) Simba plays 6 The total is 9 (Pumbaa's hand: 104, 9, 8) Pumbaa plays 104 The total is -1 (Timon's hand: 4., 5., 9) Timon plays 4. Game reverses direction (Pumbaa's hand: 9., 8., Pumbaa plays 9 Simba skips a turn (Nala's hand: 5, K, 59) Nala plays 5 The total is 4 (Timon's hand: 5., 90, 34) Timon plays 5. The total is 9 (Pumbaa's hand: 8., QV, 6.) Pumbaa plays 8. The total is 17

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems X Special Issue On Database And Expert Systems Applications Lncs 8220

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2013th Edition

3642412203, 978-3642412202

More Books

Students also viewed these Databases questions