Question: Create a class to model a single playing card in a deck of cards and name this class Card. The class should include data members

•Create a class to model a single playing card in a deck of cards and name this class Card.

•The class should include data members for rank and suit.

•Use integers to identify rank and strings to identify suit.

•Include an explicit constructor that receives a rank and suit value.

•Include setter/getter member methods for each data member.

•Include a toString() member method that returns a string showing the rank and suit of the card.

•Test this class by instantiating Card objects. Construct a deck of cards as an array and fill it with 52 cards in a complete playing deck.

•Shuffle the deck and deal 5 cards, displaying the rank and suit of each card dealt.

Step by Step Solution

3.38 Rating (148 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To create a class that models a playing card we will structure our solution into several steps Well start by outlining the class definition followed b... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!