(Solved) : Java Use Inheritance Classes Represent Deck Playing Cards Create Card Class Stores Suit Eg Q37280997 . . .
Java
Use inheritance and classes to represent a deck of playingcards.
Create a Card class that stores the suit (e.g., Clubs, Diamonds,Hearts, Spades) and name (e.g., Ace, 2, 10, Jack) of each cardalong with appropriate accessors, constructors, and mutators.
Next, create a Deck class that stores an ArrayList of Cardobjects. The default constructor should create objects thatrepresent the standard 52 cards and store them in theArrayList.
The Deck class should have methods to do the following:
-
Print every card in the deck.
-
Shuffle the cards in the deck. You can implement this byrandomly swapping every card in the deck.
-
Add a new card to the deck. This method should take a Cardobject as a parameter and add it to the ArrayList.
-
Remove a card from the deck. This removes the first card storedin the ArrayList and returns it.
-
Sort the cards in the deck ordered by name.
Finally, write a main method that creates a deck of cards,shuffles the deck, and “deals” five cards. The cards should beremoved from the deck and printed out to the console. Test the sortand print functions for the deck. Finally, return the cards in thehand to the deck and test to ensure that the cards have beenproperly returned. You may add additional methods or classvariables as desired to implement your solution
Expert Answer
Answer to Java Use inheritance and classes to represent a deck of playing cards. Create a Card class that stores the suit (e.g., C…
OR