logo

CMSC 132

Sections 030X/040X/050X
Assignment:     Project #1
Due Date:     Sunday 02/09, 11:00PM
Open/Closed policy:     OPEN

Blackjack Game


Objective

This project will give you a review/warm-up of basic Java and Eclipse, as well as providing some practice with Java's enumerated types, and the ArrayList class.


Overview

You will implement the "model" (logic and data structures) for a simulation of the game Blackjack, pictured above. The GUI (Graphical User Interface) has been provided for you.

In our game, there is just one player (controlled by the user) who plays against the dealer.

To simplify the implementation, we've left out a few features of the game that you may be familiar with if you've ever played Blackjack in a casino: splitting pairs, doubling down, surrender, insurance, and "even money" payoffs are all left out of our simplified version of the game. It's still kind of fun.


Cards

If you are not familiar with the standard deck of 52 playing cards and the terminology that goes along with it ("rank" "suit", "queen", "clubs", etc.), then please take a look at the Playing Card Page.


Blackjack hands

Even if you are an experienced player, you should review the Blackjack Hands Page. This page will define how Blackjack hands are assigned values in our game. Be sure to look over the examples near the bottom, because they describe precisely how some of the trickier Blackjack hands will be assigned values by the code that you will be implementing.


The Special Hand Called "Natural Blackjack"

There is one very special hand called the "Natural Blackjack". It consists of exactly two cards that total exactly 21. In other words: An Ace together with one of the cards with a value of 10. For example, the hand below is a "Natural Blackjack":

   

Note that a hand that totals 21 but consists of more than 2 cards is not a Natural Blackjack.

If the player has a Natural Blackjack (but the dealer does not have one) then the player wins 1.5 times his/her bet! If both the player and the dealer have a Natural Blackjack then it's a "push", which means the player neither wins nor loses.


Rules of Blackjack

Betting

Before any cards are dealt, the player places a bet, using colorful chips that represent dollar values. In our simulation there are chips representing $5 (red), $10 (blue), $50 (green), $100 (black), and $500 (pink). (See the image above.)

Initial Cards

The dealer initially deals out two cards for the player, and two cards for herself. Note that one of the dealer cards is visible to the player, and the other one is face-down (hidden).

Player's Turn

Now the player takes their turn. The player may choose to either "hit" (take an additional card) or "stay" (ending the turn). The player may hit as many times as they desire as long as the hand's total is under 21. If the total exceeds 21, the player has "busted", which means they automatically lose and their turn is over.

Dealer's Turn

Once the player has decided to "stay" (or has busted), it is the dealer's turn. At this point the dealer will flip over her hidden card so that the player can see it. The dealer in our game must always play according to the following rules:

Win, Lose, Push, or Extra Winning (Natural Blackjack)

Once the dealer has stopped taking cards, it's time to determine whether or not the player has won. Here are the cases -- read them carefully:


Getting Started

Begin by downloading the project files here. You'll need to import them into Eclipse, as described in the Importing Projects section of the Eclipse Tutorial.


What You Must Implement

Package deckOfCards

Begin by looking in the package called "deckOfCards". Take a look at the enumerations called "Rank" and "Suit", and look over the Card class. These have all been provided for you.

Your first task will be to provide an implementation of the Deck class, which represents a standard deck of 52 cards. Your implementation must include the following members:

Package blackjack

There are two Java enumerations here that you should look at first: HandAssessment and GameResult.

Your main task will be to implement the class called BlackjackModel. Include the following members:


JUnit Tests

We are providing you with a set of JUnit tests (tests/PublicTests.java) that you can run yourself on your code to test its basic functionality.

The submission server will also include "release tests", which will give you limited feedback. You can't see the release test code, and you can only see the results of these tests a limited number of times (roughly 3 times per day).

The submission server will also include one "secret test". You will not be able to see whether or not you are passing this test until after the due date has passed. It is very important for you to learn to test your own code!


Requirements

Running the Game

When you're done implementing both the Deck class and the BlackjackModel class, you can have some fun by running the GUI. Run the main method in the class GUI/BlackjackGUI. The GUI is not designed as a diagnostic tool -- you should be testing your code using JUnit tests, including the public tests that have been provided, tests you write yourself, and the release tests that are available on the submit server (see the section below).


Submitting the Project

Submit your project from Eclipse (within Java perspective) by right-clicking the project folder and selecting "submit" . If you do not see the submit option, then you are missing our plugins, which means that you did not install Eclipse according to the instructions in the Eclipse Tutorial. You may submit as many times as you want -- we will always grade the submission that we receive last.   After you have submitted your project, you should visit the submit server.  There you can obtain limited feedback about how well your project is performing.  The number of times you can run our tests on your project (before the due date) is limited.  The earlier you begin working on the project, the more opportunities you will have to see how your project performs on our tests before the due date!


Grading

Your grade will be computed as follows:

Web Accessibility

Web Accessibility