Java Reference
In-Depth Information
for (Rank rank: Rank.values())
initialDeck.add(new Card(suit, rank));
}
static List<Card> newDeck() // Return a new unshuffled
deck.
{
// Copy initial deck to new deck.
List<Card> deck = new ArrayList<Card>(initialDeck);
return deck;
}
}
Note Blackjack is a card game in which a player competes against the card dealer
toseewhocancomeclosest to21withoutgoingover.Thefirstonetoreach21wins
and ends the current round of play. The dealer begins a round by dealing two cards
to the player and two cards to herself. The player sees both of her cards and only the
first card in the dealer's hand. The dealer checks her hand fora blackjack (exactly 21
points).Whenthisisthecase,theplayerlosesunlesstheplayeralsohasablackjack.In
thissituation,theresultisknownasa push andnoonewinsorloses.Whenthedeal-
er'shandisnotablackjack,theplayercheckshercardsforablackjackandwinswhen
thisisthecase.Otherwise,sinceneitherthedealernortheplayerinitiallyhasablack-
jack, the game proceeds as follows: A player can request hits (additional cards from
the dealer—one per hit) until either the sum of a player's cards exceeds 21 (the play-
er loses) or the player decides to stand (the player is satisfied with her cards and will
waittoseehowthedealer'shandprogresses).Playerstypicallystandwhentheybelieve
theirhandsaregoodand/oranotherhitmaycausethemtoexceed21.Aftertheplayer
stands,thedealerproceedsbyshowinghersecondcardtotheplayer.Thedealeralways
takesahitwhenthesumofhercardsislessthan17,andalwaysstandswhenthesum
ofhercardsis17ormore.Whenevaluatingthedealer'sinterimscoretoseeifahitis
required,theACEalwayscountsfor11,butmaycountfor1inthefinaldetermination.
Whenthedealerisfinishedwithherhits,herhandiscomparedwiththeplayer's.When
it'shigher,thedealerwins;whenit'slower,theplayerwins(unlesstheplayerexceeded
21);andwhenthey're the same, it's apushandnoonewins.Cards deuce (2)through
10havetheirfacevalue,JACKis10,QUEENis10,KINGis10,andACEis1or11
(until the hand is evaluated).
2. Extend the Planets application with new statistics (e.g., number of moons, com-
position, and internal temperature). Also, provide additional notes (displayed via a
Search WWH ::




Custom Search