Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Database Concepts

Authors: David Kroenke

4th Edition

0136086535, 9780136086536

More Books

Students also viewed these Databases questions

Question

Write down the circumstances in which you led.

Answered: 1 week ago