Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create an abstract CardGame class similar to the one described in this chapter. The class contains a virtual deck of 52 playing cards that uses

  • Create an abstract CardGame class similar to the one described in this chapter. The class contains a virtual deck of 52 playing cards that uses a Card class that holds a suit and value for each Card object. It also contains an integer field that holds the number of cards dealt to a player in a particular game. The class contains a constructor that initializes the deck of cards with appropriate values (for example, King of Hearts), and a shuffle() method that randomly arranges the positions of the Cards in the array. The class also contains two abstract methods: displayDescription(), which displays a brief description of the game in each of the child classes, and deal(), which deals the appropriate number of Card objects to one player of a game. Save the file as CardGame.java. Create two child classes that extend CardGame. You can choose any games you prefer. For example, you might create a Poker class or a Bridge class. Create a constructor for each child class that initializes the field that holds the number of cards dealt to the correct value. (For example, in standard poker, a player receives 5 cards, but in bridge, a player receives 13.) Create an appropriate displayDescription() and deal() method for each child class. Save each file using an appropriate nameā€”for example, Poker.java, 5cards.java, Casino.java or Bridge.java. Create an application that instantiates one object of each game type and demonstrates that the methods work correctly. Save the application as PlayCardGames.java.

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

More Books

Students also viewed these Programming questions