number_cube
This is an old revision of the document!
Number Cube
- Make a new class (Object) called
Di
orNumberCube
- Make have 2 instance variables: the total number of sides, and the side currently facing up
- Make a default Constructor with no parameters that initializes the instance variables
- Make a roll method that randomly changes the current side facing up. It should return an int
return 1 + (int)(sides*Math.random() ) ;
- Override the default
toString()
method so it returns a string reporting the number facing up and how many sides it has, for example:D20 is showing 13
number_cube.1568395543.txt.gz · Last modified: 2019/09/13 13:25 by frchris