CPSC 120 Assignment #4
GUI Gambling

Due Wednesday November 7, 2007 by 4:00 p.m.

Craps is a popular casino game played by betting against the outcome of rolling a pair of dice. While there are many different variations to the game, in this assignment you will create the classes to implement a relatively simple version. For our purposes, the rules of craps are defined as follows:

To complete this assignment, you are responsible for creating three java files that are part of the assign4 package.

DicePanel.java

The DicePanel is a special JPanel that is responsible for representing your dice. The DicePanel should meet the following specifications:

Instance data:

Methods:

CrapsPanel.java

The craps panel is a special JPanel that displays the dice, buttons and labels needed to play a simple game of craps. Your CrapsPanel should adhere to the following specification:

Instance data:

Methods

A constructor with no parameters is responsible for:

Inner Classes

A ButtonListener class should be defined to respond to button presses.

CrapsApp.java

This is an application that puts the CrapsPanel into a Frame and displays it. It should be modeled after Splat.java (p186) or one of the applications from lab5.

Suggestions for Doing the Assignment

Like any programming task, you should begin by decomposing the problem into a collection of smaller, more managable tasks and working incrementally. For this assignment, you should:

  1. Create DicePanel for modeling and displaying a pair of dice.
  2. Create CrapsPanel - adding only the DicePanel
  3. Create CrapsApp
  4. Run your program to verify that you can get dice to appear on your GUI. (It they don't, check the location of the image files and the path you are using in your program!)
  5. Add the button that rolls the dice. Verify that this works.
  6. Add code to the program that allows you to play a single game of Craps.
  7. Add the second button and the logic to allow multiple games.
  8. Thoroughly test your program!! Be sure it meets all specifications.

Grading Notes

Your project will be graded on style, documentation and correctness. Some stylistic aspects you should pay attention to include the use of constants (where appropriate), identifier names, and the use of whitespace and proper formatting. You should also make sure that your submission does not contain uneccessary code, e.g. extra assignments or lines of code that have been commented out. Fifteen percent of the final assignment grade will be for style and documentation. Documentation is a critical portion of any computer program. Each method is expected to have an overall description as well as a description of each parameter and the return value - use javadoc style documentation as we did in lab (use Eclipse to help you!). Larger methods should be internally documented with descriptions of the major steps. The balance of the grade will come from correctness, which includes meeting all of the specifications of the assignment.

Turn in

A printed copy of your program files (the Java files - DicePanel.java, CrapsPanel.java CrapsApp.java). Tar all the files in your assign4 subdirectory and email the .tgz file to your instructor with a subject of cpsc120 assign4.

Academic Integrity Reminder: Assignments are to be done on your own. You may get help on the specifices of the assignment from no one but the instructor. You may not show your program to anyone else or look at anyone else's program or share ideas about how to write the program.

-----Bonus-----

After you have submitted your assignment, you are invited to enhance your program to earn some extra credit. I know that you will have lots of fun playing with your GUI craps as designed, but to really make it fun, we need to add some money into the equation (After all,this is a gambling game). Implement the following features to earn extra points.

Other substantial improvements to the game are welcomed and will be rewarded. If you are submitting bonus work you should create a text file (Bonus.txt) explaining the enhancements that you made. This file should be tar'ed together with your updated code and sent as an independent e-mail. Bonus material will not be accepted if the original submission does not meet at least 90% of the original specifications.