Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. Multisided Dice The Die class in the text assumes dice have 6 sides. You may have seen dice with 4, 10, 12, 20 sides

image text in transcribed

2. Multisided Dice The Die class in the text assumes dice have 6 sides. You may have seen dice with 4, 10, 12, 20 sides in various games. With computers we are not limited by geometric considerations and can easily create dice with any number of sides. 1. Copy the Die class from the lecture into package ca.bcit.comp1510.lab04. Change the name of the Die.java file and the class name to MultiDie (you can right-click on the Die file and use refactor>rename from the popup menu) and make whatever changes may be required for MultiDie to compile. 2. Modify the JavaDoc to reflect your modifications. You are an author, but the old authors are still needed unless you totally rewrite the code. 3. Remove the initialization from the MAX constant declaration, remove the modifier static, but keep it final. Change the name to max. The value will be set in a constructor. 4. Modify the MultiDie constructor by adding a parameter int numSides, and changing the body to initialize max to numSides and calling the roll method to initialize faceValue. 5. Modify the roll() method to use max instead of MAX. 6. Write a driver class RollingMultiDice to exercise MultiDie. If useful, you can start from the lecture's RollingDice class. 7. Answer the following questions as comments in your MultiDie class (in the class JavaDoc comments) 1. Do you need getters and setters for max? Should you have them? 2. Can you have getters and setters for max? 3. Why do you think it makes sense (or not) to have max be final? 4. What does max's being final say about the abstraction of a MultiDie object? 5. Is max an instance variable

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions