1. Engineering
  2. Computer Science
  3. gt5w assignrren gtmcg1100wa o how lo make d...

Question: gt5w assignrren gtmcg1100wa o how lo make d...

Question details

€>5W Assignrren × €>MCG1100-wa × O how lo make d Χ €> Assignmen11- ㄨ 血 index.pdf X Arrays С і https://www.eecs.uottawa.ca/-turcotte/teachingiti-1 1 21/assignments/01/index.pdf index.pdf 217 In our game, each turn begins with the roll of die. In order to support this element of the game, you must create the lass Die. * A die stores an integer value in the range l to t. inclusively. The class Die declares a single constructor, which has no parameters. The constructor initializes the value of this die with a random numher in the appropriate range. The accessor, getValue, rehans the cunrent value of the die. ◆ The nerhod roll randomly assigns a new value to this die Hint: you can lise an chiect of the class ava ntil Random to The method toString retarns a String reprscntation of this objoct. The expocted foemat is shown below Finally, the class Die declares a constant called MAXVALUE with valuc 6. Make sure that the visibility is publie and the variable is immutable Here is a terse example showing the intended use: Sytem ont printlnd.getValue ) Line 1 of the above propram declares a referenoe variable of type Die. Line 2 creates an object of the class Die and stores its reference in the referenee variabke d. Line 3 pints the current valuc of the die. Linc 4 calls the mathod roll of the object designated by d. Line 5 prints the current value of the die. Finally, Line 6, tbe method println implicitly calls the method toString of the object designated by d and prints the result Since the values are randomly generated, each run is likely to produce a diffeult. Here is the result of a possible run. Dic (value:3 6:50 PM Type here to search ^恒廳 14x 1/26/2019

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