User Tools

Site Tools


number_cube

This is an old revision of the document!


Number Cube

  1. Make a new class (Object) called Di or NumberCube
  2. Make have 2 instance variables: the total number of sides, and the side currently facing up
  3. Make a default Constructor with no parameters that initializes the instance variables
  4. Make a roll method that randomly changes the current side facing up. It should return an int
     return 1 + (int)(sides*Math.random() ) ;
  5. Override the default toString() method so it returns a string reporting the number facing up and how many sides it has
number_cube.1568395500.txt.gz · Last modified: 2019/09/13 13:25 by frchris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki