CS 280 Spring 2008

Assignment 4 – Using Existing Non-Built-In Classes  - Card, Deck, etc

100 points

 

Assigned: 02/06/2008

Due: 02/13/2008 at the start of class

 

Pre-Lab (Do Before Lab):  Bring materials – a USB for a take home copy. Plan out your GUI, tasks, objects, and events needed for program.  Download, unzip and familiarize yourself with the Classes that I’m providing. Plan out how you will solve the problem.

 

Main Assignment:

Imagine that you are writing some parts of a Blackjack program.  We are still a bit away from being able to do the full job, so pay attention to what I’m asking for. Also note that you will need to gain an understanding of the provided classes.

The provided classes will be in a zip file on Blackboard, along with documentation for the classes.  A quick introduction is included below. You should create buttons to

1.      Start/Restart a game with cleared screen and newly shuffled deck of cards. Note that there are capabilities for creating a new, shuffled deck of cards.

2.      Deal – deal two cards for yourself (display them) and calculate the points and display them. Note there is a capability for dealing a card, for calculating the points for a card, and for creating a string from a card. I recommend using a jTextArea, which is like a jTextField except it can hold multiple lines of text (see note under miscellaneous)

3.      Hit - should deal a card for you, update and display the total. You do not know branching in Java yet, so I’m NOT asking you to check on whether you’ve “busted” (gone over 21 points).

4.      Stick - should deal 3 cards for the dealer, display them, and calculate and display the dealers total. You do not know branching in Java yet, so I’m NOT asking you to determine how many cards the dealer should draw.  I’m also NOT asking you to determine the winner.

5.      Clear – clears the screen, but does not create a new deck or shuffle the deck.

6.      Exit – Exits from the program

·         Also, put your name on the GUI form as a jlabel OR on the Title Bar..

·         You’re just beginning at setting up GUIs. Don’t worry too much about making the interface nice.  See my simple sample interface below – But don’t let that constrain your creativity. Use it to help understand what I see as the inputs and outputs. The paper version of this assignment shows a couple of screen shots from different points running my program. The version on my www site shows 5 screen shots from various points.

·         But if you plan on working with 5.5 or higher version of the IDE, ask me about using layouts, panels, java version, etc so that your program will work with 5.0.

·         Enabling and making components (controls) visible is somewhat hairy here. Don’t let any troubles with that stop you from getting the rest working, or from me being able to tell that the rest is working.

·         Please set the name of the project to something other than the default name (JavaApplication1, …).  

 

Hand in:

 


Provided Classes:

 

Miscellaneous:

Card Rank

Points

ace

11

king

10

queen

10

jack

10

ten

10

nine

9

eight

8

Seven

7

Six

6

Five

5

Four

4

Three

3

Two

2

 

o    MAKE SURE YOUR PROGRAM WORKS! (i.e. gets correct results, controls what is displayed/enabled).

o    You MUST include some comments that explain your program in order to get full credit.

 

 

 

 

 

 

 

 

 

When program starts up

 

 

After clicking Restart.

 

 

 

After clicking Deal

 

 

After clicking Hit

 

After clicking Stick