Java Assignment 4 -- 21 Dice Applet

Click Reload or Refresh to roll again

This program will appear to be very similar to the previous assignment, but the code will actually be significantly different. For this version, you will need to write a Die class. You can think of this as a new data type that represents a single die from a pair of dice.

Program Requirements

  1. Your program will have two classes. A public "applet" class and a regular "non-public" Die class. Your applet class should be similar to this example:
    
    public class TwentyDice extends Applet
    {
       public void init()
       {
          setBackground(Color.magenta);
       }
       public void paint(Graphics g)
       {
    		 for(int nRow = 0; nRow < 7; nRow++)
    		   for(int nCol = 0; nCol < 3; nCol++)
    		   {
    		      Die aDie = new Die();
    		      aDie.roll();
    		      aDie.paint(g,nRow * 60 + 10,nCol * 60 + 10);
    		   }
       }
    }
    
  2. Your Die class will need one member variable: an int that holds the "roll"
  3. Your Die class will need at least two member methods:
    
    void roll()
    {
            //your code here
    }
    void paint(Graphics g, int nX, int nY)
    {
            //more of your java code here
    }
    
    
  4. Note: You will need to upload both class files to your website!

You will need a web page to display your applet. Your homepage should have a link to the web page for this assignment.

Submit the URL of your applet along with your Java code (the .java file) in an email message to mrsimon@lycos.com.