Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help code the program in Java, as simple as possible. The kids card game Six Card Golf is to have the lowest total value of

Help code the program in Java, as simple as possible. image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
The kids card game Six Card Golf is to have the lowest total value of cards. Create a program that evaluates 4 hands of this game. Note that this assignment does not involve a game simulation, this is simply an evaluation of dealt hands. The cards are arranged in a 3x2 grid, and the following rules for scoring apply: Score values are assigned for each face (see below in #2) - A pair of equal faces in the same column scores zero points for the column (even if the equal cards are 2s). - See sample output for examples. Consider the following UML diagram: > SetOfCards Card # cards max - Suit - face 1 contains + SetOfCards() + getCards() + setCards(...) + addCard...) + evaluate() + toString() + Card(...) + getSuit() + getFace() + toString() Deck + Deck() - createCards() + shuffle) + deal() Hand + Hand + Hand...) access control: public private protected Create a hierarchical class structure according to the UML. 1. Create the following enums: a) Face: includes the 13 faces of a deck of playing cards: ace, two, three... ten, jack, queen, king include fields: - display- the string representation of the face (e.g. A, 2-10,J,Q,K) points - the point scoring for each face: face points Ace 1 2 -2 3 to 10 face value Jack or Queen 10 King 0 b) Suit: includes the suits of a deck of playing cards: clubs, spades, hearts, diamonds Include a display field that is the string representation of the suit. suit unicode Clubs \u2663 Spades \u2660 Hearts \u2665 Diamonds \u2666 2. The card class has fields suit and a face of types suit and Face, respectively. include one constructor: full-arg that assigns the passed suit and face Include getters for each and override the tostring method to return a string in the format suit> 0 N etc... 3. The abstract class Seto Cards must have an ArrayList of cards and an integer that represents the maximum number of cards in the set. Include the following methods: a no-arg constructor that initializes an empty array list of cards a getter and setter for cards, and an addcard() method to add to the set Ensure that setting a list or adding a card does not go over the maximum number of cards for the set abstract method evaluate that returns a string tostring that lists all the cards in the set in the format ( . ] e.g. [9 26 K ] Use StringBuilder to create this string 4. Subclasses Deck and Hand extend the SetofCards class a) Include the following methods in the Deck class: a no-arg constructor that assigns the max to 52 and creates the deck - Include a private utility createcards () that creates and adds all 52 cards in a deck (i.e. each face of each suit). Call this method in the constructor. (note that it may not be necessary to define 13 or 52 as constants but those values should be commented to indicate their purpose, i.e. // 13 number of cards per suit) shuffle () that randomly orders the cards. See the Java documentation for Collections. shuffle deal() removes and returns the first card of the deck Implementation of the evaluate() method: Return a string that indicates the size of the deck, the size being how many cards are currently in the deck. Each deck will start off with 52 cards and will shrink as cards are removed. b) Include the following methods in the Hand class: - a no-arg constructor that assigns the max to 6 a constructor that assigns the max and an array list of Card objects to cards evaluate () that returns a String that represents the hand: Sum of card points (accessed through enum) Include the scoring for columns of pairs: If matching faces are found within a column, 0 points are scored for each card in that column toString() override to display in a 3x2 grid (see sample output) Use stringBuilder to create this string 5. Include a driver class called SixcardGolf that deals 4 hands from the deck and displays the result of each. - Create an instance of a deck Shuffle the deck of cards, then simulate: For each player: deal 6 cards from the deck to create a hand display the cards and the result of the hand See format in sample output Display the number of cards remaining in the deck. Sample output: Player 1: 9 5 K 29 Score: 30 Player 2: JV 7. 3 A. Score: 29 Player 3: 000 34 Score: 43 Player 4: 10. A 5 10 QM Score: 20 Number of cards remaining in deck: 28 Notes: Hand only requires the cards to be displayed in 3x2. You may use any way to determine pairs/column Auxiliary arrays and/or ArrayLists may be used, cards must be of type ArrayList Additional cases (cards with face 2 columns in pairs, adding more than max number of cards, etc.) will be tested by the marker The kids card game Six Card Golf is to have the lowest total value of cards. Create a program that evaluates 4 hands of this game. Note that this assignment does not involve a game simulation, this is simply an evaluation of dealt hands. The cards are arranged in a 3x2 grid, and the following rules for scoring apply: Score values are assigned for each face (see below in #2) - A pair of equal faces in the same column scores zero points for the column (even if the equal cards are 2s). - See sample output for examples. Consider the following UML diagram: > SetOfCards Card # cards max - Suit - face 1 contains + SetOfCards() + getCards() + setCards(...) + addCard...) + evaluate() + toString() + Card(...) + getSuit() + getFace() + toString() Deck + Deck() - createCards() + shuffle) + deal() Hand + Hand + Hand...) access control: public private protected Create a hierarchical class structure according to the UML. 1. Create the following enums: a) Face: includes the 13 faces of a deck of playing cards: ace, two, three... ten, jack, queen, king include fields: - display- the string representation of the face (e.g. A, 2-10,J,Q,K) points - the point scoring for each face: face points Ace 1 2 -2 3 to 10 face value Jack or Queen 10 King 0 b) Suit: includes the suits of a deck of playing cards: clubs, spades, hearts, diamonds Include a display field that is the string representation of the suit. suit unicode Clubs \u2663 Spades \u2660 Hearts \u2665 Diamonds \u2666 2. The card class has fields suit and a face of types suit and Face, respectively. include one constructor: full-arg that assigns the passed suit and face Include getters for each and override the tostring method to return a string in the format suit> 0 N etc... 3. The abstract class Seto Cards must have an ArrayList of cards and an integer that represents the maximum number of cards in the set. Include the following methods: a no-arg constructor that initializes an empty array list of cards a getter and setter for cards, and an addcard() method to add to the set Ensure that setting a list or adding a card does not go over the maximum number of cards for the set abstract method evaluate that returns a string tostring that lists all the cards in the set in the format ( . ] e.g. [9 26 K ] Use StringBuilder to create this string 4. Subclasses Deck and Hand extend the SetofCards class a) Include the following methods in the Deck class: a no-arg constructor that assigns the max to 52 and creates the deck - Include a private utility createcards () that creates and adds all 52 cards in a deck (i.e. each face of each suit). Call this method in the constructor. (note that it may not be necessary to define 13 or 52 as constants but those values should be commented to indicate their purpose, i.e. // 13 number of cards per suit) shuffle () that randomly orders the cards. See the Java documentation for Collections. shuffle deal() removes and returns the first card of the deck Implementation of the evaluate() method: Return a string that indicates the size of the deck, the size being how many cards are currently in the deck. Each deck will start off with 52 cards and will shrink as cards are removed. b) Include the following methods in the Hand class: - a no-arg constructor that assigns the max to 6 a constructor that assigns the max and an array list of Card objects to cards evaluate () that returns a String that represents the hand: Sum of card points (accessed through enum) Include the scoring for columns of pairs: If matching faces are found within a column, 0 points are scored for each card in that column toString() override to display in a 3x2 grid (see sample output) Use stringBuilder to create this string 5. Include a driver class called SixcardGolf that deals 4 hands from the deck and displays the result of each. - Create an instance of a deck Shuffle the deck of cards, then simulate: For each player: deal 6 cards from the deck to create a hand display the cards and the result of the hand See format in sample output Display the number of cards remaining in the deck. Sample output: Player 1: 9 5 K 29 Score: 30 Player 2: JV 7. 3 A. Score: 29 Player 3: 000 34 Score: 43 Player 4: 10. A 5 10 QM Score: 20 Number of cards remaining in deck: 28 Notes: Hand only requires the cards to be displayed in 3x2. You may use any way to determine pairs/column Auxiliary arrays and/or ArrayLists may be used, cards must be of type ArrayList Additional cases (cards with face 2 columns in pairs, adding more than max number of cards, etc.) will be tested by the marker

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

Step: 3

blur-text-image

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 1 Lnai 6321

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215879X, 978-3642158797

More Books

Students also viewed these Databases questions