Playing With Cards
Write a class that defines an enumerated type named
ace, two, three, four, five, six,
seven, eight, nine, ten, jack, queen, king.
The main method
should do the following:
of type Rank.
Assign highCard to be an ace, faceCard to be a jack, queen or king (your choice), and card1 and card2 to be two
different numbered cards (two through ten - your choice).
Print a line, using the highCard and faceCard objects, in the following format:
A blackjack hand: ace and .
The faceCard variable should be printed instead of the dots.
Declare two variables card1Val and card2Val of type int and assign them the face value of your card1 and card2
objects. Use your card1 and card2 variables and the ordinal method associated with enumerated types. Remember
that the face value of two is 2, three is 3, and so on so you need to make a slight adjustment to the ordinal value of
the enumerated type.
Print two lines, using the card1 and card2 objects and the name method, as follows:
A two card hand:
(print card1 and card2)
(print the sum of the face values of the two cards)
Chapter 3: Using Classes and Objects