A. Goals
The purpose of this assignment is to practice using ArrayLists and Interfaces. The specific goals are to:
- Implement 3 interfaces of objects in a game of blackjack
- Become familiar with iterating through and modifying ArrayLists
Face cards (Kings, Queens, Jacks) are worth 10 points, Aces are worth 1 or 11 points, and all other cards are worth their face value. The human player goes first, making his or her decisions based on the single dealer card showing. The player has two choices: Hit or Stand. Hit means to take another card. Aug 08, 2019 Recall Aces can assume a value of 1 or 11 depending on the strength of the hand. A soft 17 is one which contains an ‘Ace’ that counts as 11, and the other cards sum to 6. With a hard 17, the ‘Ace’ can only assume a value of 1. BLACKJACK RULES AT THE CASINO. Blackjack is the #1 most popular casino card game. A 10-up blackjack will be revealed immediately after peeking, and the player will lose only his original wager, except a blackjack tie will push. BB+1 refers to an Australian rule, in which the player will lose all busted bets, plus one unit, if the dealer gets a blackjack.
B. Background
Blackjack is a popular card game, common as a table game at casinos. The goal of blackjack is to draw cards, scoring as close to 21 points without going over.
Blackjack uses a standard deck of 52 cards, with 4 possible suits, Hearts, Diamonds, Clubs, and Spades, and 13 possible values. These are shown in the image below.
Each card has a 'score'. All the cards in a hand are added up in hopes of reaching 21 without going over.
- Numeric cards (2 through 10) are worth the same points as their number. I.e., a 2 card is worth 2 points, a 10 card worth 10 points, a 5 card with 5 points, etc.
- 'Face cards' (Jacks, Queens, and Kings) are worth 10 points
- An Ace can be worth EITHER 1 point or 11 points, whichever results in the 'best' score (best being the closest score to 21 without going over)
- The suit of a card does not affect its blackjack score.
In blackjack, a player plays against a dealer, or 'house'. Often the dealer plays on behalf of a managing casino. If a player's hand is closer to 21 than the dealer without going over, the player wins. If the player goes over 21, or is further from 21 than the house, they lose. In the case both the player and the house have the same score under or equal to 21, it's called a 'push', or a tie.
The best situation for the player is to get dealt an Ace and a card worth 10 points. If this happens, the player already has 21 points with two cards, and automatically wins (even if the dealer also has 21). This hand is called a blackjack.
In most cases of blackjack, both the player and the dealer start with 2 cards in their hand, with the player having both cards face up, so their value and suit is visible, while the dealer shows only one card face up, and the other 'hidden' face down. The player then decides to 'hit' (draw another card to add to their hand) or 'stand' (draw no more cards and end their turn. Once you stand, you can no longer draw any cards. However, if you 'hit', and your total goes over 21, you lose automatically, and the dealer never has to take their turn, winning automatically.
In blackjack the player must always play their turn before the dealer. This means the decision for the player to 'hit' is based on the risk of going over 21. If a player has a 17, for example, it is unlikely they should 'hit', as there is roughly a 10/13 chance that the player will 'bust' (go over 21). Likewise, if you have a total score of 5, you absolutely should hit, since it's almost certain the dealer will have a higher score just with two cards alone. That is, unless you like to live dangerously.
Because the dealer always goes after the player, the 'house' (or casino) has a slight advantage, winning about 5% more often than the player. Hey, gambling is a business.
C. Your program
In this assignment, you will write a Card
, Hand
, and Deck
class. Each class implements an interface, HW8Card
, HW8Hand
and HW8Deck
respectively. You will implement all of the methods in the interfaces in their respective class files.
- Card implements functions related to a single card in a standard deck of 52 used in blackjack.
- Deck implements functions that simulate the behavior of a real deck of cards.
- Hand implements functions that add to and score a hand of blackjack.
D. Designing the Requirement and Interface
- Download
hw8.zip
and decompress it into your folder for this homework assignment. This zip file contains the three files you will edit, as well as three interfaces (HW8Card
,HW8Hand
, andHW8Deck
) andBlackjack.java
, which executes a game of blackjack using the code you will write.Do not edit HW8Card
,HW8Hand
,HW8Deck
, orBlackjack.java
at all.HW8Card
,HW8Hand
, andHW8Deck
areinterfaces . Each file you submit implements these interfaces. This is done by writing an implementation for each function in the interface.Blackjack.java
is the 'Main' class in this program, which uses the other files (including yours) to run a Blackjack program. This file will only work when you complete the homework and you can run the file to simulate a blackjack game.
- Review the class material on ArrayLists and class material and textbook on interfaces.