Black Jack Design — Class Diagram and Chart

Class Diagram

Classes shown in blue are complete and do not require modification in any way.

Item

Type

Description

Main class This class contains a short main method used to run the program. No modifications necessary.
GameView class This is part of the GUI (Graphical User Interface) for the game. You do not need to understand or modify it.
PlayerView class This is part of the GUI for the game. It displays a frame for an individual player, including the cards the player currently holds, the value of those cards, and a button labelled “Hit Me” to indicate the player wants another card dealt. You do not need to understand or modify this class.
Player class This class represents a player.
hand attribute The cards the player has been dealt so far.
name attribute The player's name.
<missing attributes> attribute The missing attributes should be pretty obvious from the methods.
Player constructor Constructs a Player object. The player will have a name, but no cards and won't have won any rounds yet.
reset method Prepares the player to play a new round.
getPlayerName method Returns the player's name.
getScore method Returns the sum of the values of all the cards currently held in the player's hand.
incrementRoundsWon method Increment the number of rounds won for this player.
getNumRoundsWon method Return the number of rounds won for this player.
addCard method Adds a card to this player's hand.
getHand method Returns a completely filled array of the cards in the player's hand. Used by the PlayerView to display the hand.
Deck class This class stores and processes information for a deck of cards.
deck attribute The CardList object that contains the Cards of the deck.
Deck constructor Constructs a deck of 52 cards and shuffles them into a random order.
dealCard method Returns the “next” card in the deck, removing it from the deck.
Card class Represents one playing card such as the “five of diamonds”. This class is complete. You should understand it but you do not need to modify it. See Card.java for further documentation.
CardList class Stores and manipulates a list of Card objects. The cards must be stored in a partially-filled array that is initially allocated to hold only 1 card. Obviously, the array must grow as necessary.
<missing attributes> attribute The missing attributes should be pretty obvious from the methods.
CardList constructor Construct a new, empty, list of cards.
add method Add a new card to the list.
size method Return the number of cards currently in the list.
get method Return the card at the given position in the list.
removeLast method Remove the last card in the list and return it.
shuffle method Put the cards into a random order.
clear method Logically remove all the cards from the list.
toArray method Return a completely filled array with all the cards currently in the list.
BlackJack class

This is the class that controls the play. It keeps track of the players in the game as well as the deck of cards. It deals another card to players, as requested. It also begins a new round of play by figuring out who the winner is and telling that player to increment the number of rounds it has won.

The players must be stored in a partially-filled array that need not grow because at most 6 players can play.

addPlayer method Add a new player to the game.
hitPlayer method Deal another card to the specified player.
newRound method Begin a new round of play. Each player will have an empty hand.
getNumPlayers method Return the number of players in the game.