CS112: In-class Exercise 5 (Improved Version) 1. We will continue with the rolling-dice project. By now, you should have a working Die class in the project. (Remember, a project is just a collection of classes.) The Die class should have one constructor (that initializes the object by rolling the die), and two methods getValue() and roll() , both of which should return the value of the die. If not, you should first fix this. 2. Click on New Class . Give the new class the name of Dice . 3. This new class will make objects that each simulates rolling a pair of dice. Now edit the source file. Get rid of all the junk that comes by default with the source file . 4. Fields: Declare two instance variables each of which is a Die object. For example… private Die die1; 5. Overall philosophy: We will be applying methods to die1 and die2 , so we will not have to redo any of the math inside the Die class. 6.
This is the end of the preview. Sign up
access the rest of the document.