email me at borlaj@portlandschools.org

Loading
notes previous (12/<12) submit the dump links  
 

Dice Project

 

Start with the Gui Bulider and create a gui with at least 3 text fields and a box rename it Proj_Dice

 

Basic Version:

The rules of our game is if they get doubles (like 1,1 or 2,2, etc), or they get a total of 7 (like 6 and 1) or 11, then they win, otherwise the lose.

 

The way the game proceeds:

  • Where they will start with 500 and they can bet whatever they want (in the bet field).
  • When they hit roll button, the result will show what they rolled.
  • After it shows what they got, it says if they lost or won, the money will either go up or down the amount they bet.

Advanced - if you want a more interesting game - follow the rules for craps here

 

EMAIL ME ANY QUESTIONS borlaj@portlandschools.org

 

 

 

Advanced students, play craps (see here) have it draw the roll or show the image of the dice. This is challenging, your code will look a bit like below:

  if (source==roll)
        {
            //all your code about rolling
            Graphics g=getGraphics(); //to draw we need the graphics 
            //lets draw the first die
            g.drawRect(45,45,60,60); //draw a square face
            if (dice1==1)
                g.drawOval(50,50,4,4); //draw one dot for the circle
                //or
                drawImage(oneDie,40,40);
        }

Make some fields uneditable. (bmiTextField.setEditable(false);

More options, use textarea to have a running of the game.

To pause execution (like animation): Put below in your code (all of it)

 try{
   Thread.currentThread().sleep(1000); 
	}
  catch(InterruptedException ie){}
 
 

 

 

 

14 Point Rubric

  • Variables named appropriately - 1 point
  • Indented properly - 1 point
  • GUI setup correctly (all nec fields and labels and button included) - 2 points
  • Money starts with 500 and is uneditable - 1 point
  • Fields that should be uneditable are - 1 point
  • Button is listened to - 1 point
  • When rolled a random roll appears - 2 points
  • Win or lose determined correctly - 1 point
  • If win or lose money updated correctly - 2 points
  • Out of money refuses to let user play more - 1 point
  • Refuse to let user bet more than they have or 0 or neg - 1 point

Advanced Rubric - Advanced students need to have at least 2 points:

  • Graphics of some kind show roll - 2 point
  • Made the game craps instead- 2 point
  • Sound - 1 point
  • Some other feature - 1 point