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.
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);
}
}
}
Die
class will need one member variable: an int
that holds the "roll"
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
}
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.