Question: how to do this using kotlin Die.kt Write a class (Die.kt) that closely replicates dice: - Properties to describe the die - Type - or

 how to do this using kotlin Die.kt Write a class (Die.kt)

how to do this using kotlin

Die.kt Write a class (Die.kt) that closely replicates dice: - Properties to describe the die - Type - or name, or colour (eg d20) - Number of sides (eg 20) - Current side up - A primary constructor that can accept 0,1, or two arguments - Default typeame: "d6"; default number of sides: 6 ; random side up generated from the roll method - Number of sides is the parameter. Default typeame: "d\{number of sides } " random side up generated from the roll metho - Both the number of sides and the type are parameters; random side up generated from the roll method - Appropriate accessors and mutators - Things to consider: - Should you let the user change the number of sides? - If you can change the number of sides, should you also change the typeame? - A roll method to generate a random value - Your roll method can make use of built-in random functions like Random.nextInt(). - roll is a special set method that doesn't take any arguments and shouldn't return a value DiceGame.kt Write a runner class (DiceGame.kt) to test your Die class: - Create different sized dice using each constructor - Roll the dice and display their results (before and after) - Choose one Die object and set it to show it's highest value - Create 5 six-sided dice. Roll each Die in a loop until you get 5 of a kind. Count and display the number of rolls

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!