Add Six Dice and Calculate Points
Add six dice to the panel and learn to calculate points depending upon the dice numbers.
Adding six dice to the dice panel
For testing purposes the program will need to be able to create dice with specific values.
- Add another constructor with one parameter, an integer called
value
. - Use
this
to set the instance variablevalue
to the parametervalue
. - Add a mouse listener that calls
click()
when the mouse is released. Use JPanel’saddMouseListener()
method, with a newMouseAdapter
object as the parameter value. In theMouseAdapter
, add a public method calledmouseReleased()
.mouseReleased()
should have one parameter, aMouseEvent
, and return nothing. InmouseReleased()
, callclick().
...
___________ Die(______) {
________.value = ________;
addMouseListener(new _________________ {
____________ mouseReleased(__________) {
____________;
}
});
}
...
Get hands-on with 1200+ tech skills courses.