Yahtzee game - due March 13th or 14th


  1. Here is your Lab 4 Yahtzee game assignment.

  2. Here is an email note about the Yahtzee game and two of the different PIVs that are needed: Two PIVs for storing the 1, 2, 3, 4, 5 or 6 are recommended.

  3. Clarification on the canvas and the this Java keyword used to refer to the methods or the PIVs of the current object.

    this.canvas = canvas;

  4. You do NOT need to use the this.canvas = canvas idea, unless you wanted to have your roll() method create a new RED LINE for every roll that the user did. Then it would need to know where, from the PIV canvas! There are 14 RED lines drawn on the Yahtzee game shown below, representing the 14 times that the user clicked the Reroll button.

       // From the Die class, with the lines to implement the roll
       // removed, but with the two statements that draw a RED LINE
       // and prepare for the position of the next RED LINE shown.
       // Note how this would NOT work, except for the PIV canvas!
       //                                                  ------
       public void roll()
       {
    
          //                               ------
          new Line(150, lineY, 250, lineY, canvas).setColor( Color.red );
          //                               ------
          lineY++;
       }
    

  5. Chapter 4 - Defining your own classes - T-Shirts example.