Question: Modify the application of Figs. 7.117.13 to use Face and Suit enum types to represent the faces and suits of the cards. Declare each of

Modify the application of Figs. 7.11–7.13 to use Face and Suit enum types to represent the faces and suits of the cards. Declare each of these enum types as a public type in its own source-code file. Each Card should have a Face and a Suit instance variable. These should be initialized by the Card constructor. In class DeckOfCards, create an array of Faces that’s initialized with the names of the constants in the Face enum type and an array of Suits that’s initialized with the names of the constants in the Suit enum type. 

Fig. 7.11

I // Fig. 7.11: Card.java 2 // Card class represents a playing card. 23 3 4 public class Card { 5 56700 6 7 8

Fig. 7.12I // Fig. 7.12: DeckOfCards.java 2 // DeckOfCards class represents a deck of playing cards. 3 import

Fig. 7.13

I // Fig. 7.13: DeckOfCards Test.java // Card shuffling and dealing. 2 3 4 public class DeckOfCards Test { //

I // Fig. 7.11: Card.java 2 // Card class represents a playing card. 23 3 4 public class Card { 5 56700 6 7 8 9 10 II 12 13 14 15 16 17 18 } private final String face; // face of card ("Ace", "Deuce", ...) private final String suit; // suit of card ("Hearts", "Diamonds", // two-argument constructor initializes card's face and suit public Card (String card Face, String cardSuit) { this.face = cardFace; // initialize face of card this.suit = cardSuit; // initialize suit of card } // return String representation of Card public String toString() { return face + " of " + suit; }

Step by Step Solution

3.35 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The instructions given are to modify an existing Java application that models playing cards and a de... 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 Java How To Program Late Objects Questions!