1. Engineering
  2. Computer Science
  3. in java 80 or greater please...

Question: in java 80 or greater please...

Question details

2.1 Die (10 marks) la our game, each turn begins with the roll of die. In oeder to suppon this elemem of the game, you must create the class Die. . A die stores an imeger value in the range 1 to 6, inclasively ·The class Die declares a single constructor, which has no parameters. The constructor initializes the value of this die with a random number in the appropeiate range The accessor, getValue, returns the current value of the die. The method roll randomly assigns a new value to this die. Hint: you can use an object of the class java.util.Random to generme pscudorandom numbers The method toString returns a String representation of this object. The expected format is shown bekow. Finally, the elass Die declares a constant called MAXVALUE with value 6. Make sure that the visibelity is public and the variable is immutable Here is a terse example showing the intended use: Systen out printlnd getValue 0) 5Systen out printlnd. getVelse ) Systen out-printind Line 1 od the above program declares a reference variable of type Die. Line 2 creates an object of the class Die and stores its reference in the reference variable d. Line 3 prints the current value of the die. Line 4 calls the method roll of the object designated by d. Line 3 prints the curvens value of the die. Finally. Line &, the method printin implicialy calls the method teString of the object designated by d and prints the result. Since the values are randomly generated, each run is likely to produce a difterent result. Here is the resulh of a possible run. Die value:3

in java 8.0 or greater please

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution