Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA This is for java. My assignment is to complete the one mentioned below. I have attached screenshot of the assignment. Please use the starter
JAVA This is for java. My assignment is to complete the one mentioned below. I have attached screenshot of the assignment. Please use the starter code give. Thanks!
Create a Card class that represents a playing card with a face value and a suit. Modify the skeleton file below k * A Card class represents a playing card with a face value and a suit. @author: PLACE YOUR NAME public class Card public static final int CLUBS-0; public static final int SPADES 1; public static final int HEARTS-2; public static final int DIAMONDS 3; // DECLARE OTHER INSTANCE DATA HERE: // CREATE THE CONSTANTS FOR ACE, TWO, THREE, // YOU MAY USE ENUMERATed TYPES HERE TOO JACK, QUEEN, KING , Default constructor that creates a card with the given values * @param face integer representing the value of the Card @param suit integer representing the suit of the Card public Card(int face, int suit) /INITIALIZE YOUR DATA HERE /**getFace method: *accessor method that returns the face value of the Card * @return an int, the face value of the Card public int getFace( return 0; //EDIT THIS public int getSuitO return 0 /**toString method * String representation of the obiect ereturn a String public String toStringO return null; //EDIT THIS //ADD OTHER METHODS NEEDED Then create a class called DeckofCards that stores an array of 52 objects of the Card class. (A skeleton file has been supplied as well.) As part of its instance data, keep a count of how many cards there are in the deck that hasn't been dealt out. At the beginning, the deck has a total of 52 cards. But as the method deal (described below) is called, this count should decrement. The behavior of this class is defined by the following methods: public void shuffleO o Randomly swaps the 52 cards. This method should assume a full deck. Recall how we swappecd elements for our encryption exercise in class. Use that same shuffing logic here. public Card deal o Removes a card from the deck o Hint: Always "remove" the last card. The card will technically still exists in the array, but we will never deal it again. If the card located beyond our current card count, we ignore i o Update the deck's count of cards to reflect that there is one less card. int getCardCountO o Reports the number of cards left in the deck * Deck of cards that has a collection of 52 Card objects. * @author: PLACE YOUR NAME public class DeckOfCards //PLACE INSTANCE DATA HERE * Dafault constructor: * Constructor creates 52 Card objects and *initializes each appropriately. No two cards are the same public DeckOfCardsO //initialize Instance Data * Shuffle method: * randomizes the order of the stored 52 cards public void shuffleO /WRITE CODE *toString method: *@overrides toString method to display all 52 cards public String toStringCO return null * deql method: removes a Card from the deck public Card dealO return null; *getCardCount * determines how many cards are left on the deck public int getCardCountO return 0 Then create a driver class called Dealer, with a main method that prints out the ordered deck, shuffles the cards and then deals each card one by one, printing each card as it is dealtStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started