Cards - public static void main(String args) { Rank...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//********************************************************************* // Cards.java // // Illustrates the use of enumerated types by creating some playing // cards using a Rank type and printing out information about them. //******************************************************************** public class Cards { enum Rank {ace, two, three, four, five, six, seven, eight, nine, ten, jack, queen, king} //-------------------------------------------------- // Define some cards using the Rank enumerated type // and print out info about them. //--------------------------------------------------
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: public static void main(String args) { Rank highCard; Rank faceCard; Rank card1, card2; int card1Val, card2Val; highCard = Rank.ace; faceCard = Rank.queen; card1 = Rank.three; card2 = Rank.five; System.out.println("A black jack hand: " + highCard.name() + " and " + faceCard.name()); card1Val = card1.ordinal() + 1; card2Val = card2.ordinal() + 1; System.out.println ("A two card hand: " + card1 + " and " + card2); System.out.println ("Hand value: " + (card1Val + card2Val)); } }...
View Full Document

Ask a homework question - tutors are online