Getting started
Start by downloading
a ZIP file containing
an almost complete NetBeans project
named Blackjack
.
Unzip this file into your
NetBeansProjects directory,
start up NetBeans and load the project.
Task description
Congrats!!! You have been hired to work as a collaborator on a project to implement the card game BlackJack.
Note that your coworkers have already implemented the main class
Blackjack
and the classes PlayingCard
and DeckOfCards
.
They have also started work on the
BlackjackHand
class which you must complete
according to the following design:
- Create three instance variables:
cards
: an array ofPlayingCard
representing a hand of cards. The hand can hold at most five cards.numCards
: number of cards currently in the handdeck
: aDeckOfCards
object for which cards are dealt.
- Complete the constructor method
BlackjackHand(DeckOfCards)
. The constructor should use itsDeckOfCards
parameter to initialize thedeck
instance variable and place two cards of the deck into the hand of cards. The number of cards should be two at this point. - Complete five methods:
public int valueOfHand()
: returns point value of handpublic int sizeOfHand()
: returns number of cards in handpublic void hitMe()
: adds a card to the handpublic PlayingCard mostRecent()
: returns the most recent card added to handpublic void printHand()
: prints the cards in the hand.
In Java files of the project each method is proceeded by comments offering implementation hints and tips. Read these carefully.
Implement and test your code. Submit only your BlackjackHand.java file.