CS-4811

Program #1

Blackjack

 

Date:            Wednesday, December 5, 2001

Due:            Wednesday, December 19, 2001

 

 

The purpose of the assignment is to simulate the card game ‘Blackjack’.  The user will be the ‘Player’ and the computer will be the ‘Dealer’.  For now, only a two-player version of the game is to be implemented.  Keep the basic game of Blackjack simple.  No splitting pairs or ‘doubling down’; just let the players pick as many cards as they request until they stop or go over 21 points (if a player goes over 21 points, they ‘bust’, and thus lose that game).  All cards have their ‘face’ value in points.  Jacks, Queens, and Kings are worth 10 points and Aces are either 1 or 11 points.  The general rule on Aces is to value them at 11 points unless that would cause the player to break 21 (in this case, count Aces as only one point).  The user can take as few or as many cards as they like, but the Dealer (the computer) must take a hit on 16 points or less and must stay on hands of 17 points or more.  The player goes first and the dealer always goes last.

 

The game should have one computer player and one player as the user of the program.  Basically, it’s the computer (the Dealer) against the user.  The computer will need to act as the Dealer, so it will need to have a function to ‘shuffle’ the cards and one to ‘deal’ the cards, as well as one to ‘play’ the game (i.e. tell the user their total and let them know if they’ve ‘won’, ‘lost’, or ‘broke’ (went over 21 points)).  Keep a running total of the number of games won and lost for the user.

 

For now, the User Interface (UI) can be console-based I/O of text messages between the user and the game.  Later on, we’ll redo the UI to utilize the JFC/Swing graphics class library.

 

For a basic primer on the rules of Blackjack, read section 2.0 of the following web page:

 

http://www.blackjackinfo.com/bjrules.htm

 

Alternative Assignment

Since the purpose of this assignment is to familiarize the student with the object model and methods of Java (and not the rules of Blackjack), you may wish to tackle a different object-oriented assignment.  For instance, a typical Banking application would work also.  In such a program, customers have attributes (name, address, account no.) and there’s a need to collect objects into a container (customers into a customer list) in order to produce reports (a summary of all transactions conducted during a particular day).  This program also can be converted from a text-based solution into a graphical program for the next assignment on using the Java Foundation Classes (JFC).  Be creative with your application domain selected, but make sure your domain is object-oriented, requires containers of objects for some processing purpose (i.e. shuffling the cards, generating a bank transactions ledger, etc.), and has a graphical interface (to be designed and implemented next) that simplifies the user interface to the program.