email me at borlaj@portlandschools.org
notes previous (09/07/06) submit the dump links  
 

Project Craps - 11 points:

 

This is due . You can reuse much code from Blackjack.

 

You are going to create a GUI craps game. Lets first review the rules of craps.

 

In craps a game is won if a 7 or 11 is rolled on the first "come-out" roll and if that first roll is 2, 3 or 12, they lose. If it is not one of those rolls, then that score becomes the point. The person then continues to roll until they roll that point again (in which case they win), or they roll a 7 (in which case they lose).

  1. Initially, start the player with $10,000
  2. Display the instructions
  3. When they hit bet, check bet (make sure its vaild), display the first roll on the screen (if the sum is 7,11 they win if it is 2,3,12 they lose).
  4. If it is not a deciding roll,tell them the point roll is ___ and to hit the roll button again to roll again
  5. If it is the point roll, tell them they won, if it is a 7, tell them they lose. Otherwise go to 3
  6. Update the amount of money they have and repreat 2 (if they have positive money)

Create this all in a class Craps based on SimpleExample from GUI. You will need at least these methods:

  • method rollDice which returns the sum and displays each of the 2 dice in the textarea.
  • method printInstructions that will display the instructions of craps in the textarea
  • method winner that will comment and update money
  • method loser that will comment and update money
  • method rollFirstDice() that will roll the "come-out" roll and decide if they are a winner, or loser, or neither and call the methods winner/loser or update the game
    • this method willl probably be called when the user hits bet
    • it will call rollDice saving whats gets returned
    • if that is a deciding amount (7,11,2,3,12) then it calls winner or loser
    • else it will set the point (which should be a field)
  • method rollFollowUp() that will roll the dice again and decide if they are a winner, or loser, or neither and call the methods winner/loser
    • this method will probably be called when they hit roll
    • it will call rollDice saving whats gets returned
    • if that is a the point or 7 then it calls winner or loser

 

Rubric: (11 points)

  • each of the 6 methods above work correctly 1 point each
  • the gui is set up correctly with the necessary textfields,buttons and textarea-notes on using textarea(2 points)
  • variable and code named approp 1 point
  • code is commented 1 point
  • code is indented properly 1 point

Extra credit:

Do anything that would make this better, like:

  • Make sub fields not editable (ie moneyField.setEditable(false);
  • Make the dice visual (put in repaint() and put some code in paint
  • make a look better
  • make the game work better (so it can only play once)