Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(RUBY) Implement Dice Thrower : 4 OPEN IDE Create a Die class o It should be initializable with a pip count o Apip is the

(RUBY)

image text in transcribed

Implement Dice Thrower : 4 OPEN IDE Create a Die class o It should be initializable with a "pip" count o Apip" is the "dot" on the side of a die The pip count you initialize a Die with is the largest number the Die can create . If the Die is initialized without a pip count, it should default to 6 (a classic, cubical die) dots on the side of the die) o max_pips should be accessible via attr_reader A method pips should return max_pips. o A method called roll should return a random pip value. The die knows its own max_pips so we can expect this Number to be between 1 and max_pips Create a DiceRoller class o It should be initializable with two arguments: - REQUIRED: the number of dice that should be created OPTIONAL: the number of pips each die should have as its maximum. If it is not provided, the count should default to 6 . By default it should initialize with a set of 1 instance of Die o The generate_set method should return an Array of the initialized number of dice o It should store the results of generate_set in an instance variable o It should implement a method called dice that returns the generated set stored in the previous step Implement Dice Thrower : 4 OPEN IDE Create a Die class o It should be initializable with a "pip" count o Apip" is the "dot" on the side of a die The pip count you initialize a Die with is the largest number the Die can create . If the Die is initialized without a pip count, it should default to 6 (a classic, cubical die) dots on the side of the die) o max_pips should be accessible via attr_reader A method pips should return max_pips. o A method called roll should return a random pip value. The die knows its own max_pips so we can expect this Number to be between 1 and max_pips Create a DiceRoller class o It should be initializable with two arguments: - REQUIRED: the number of dice that should be created OPTIONAL: the number of pips each die should have as its maximum. If it is not provided, the count should default to 6 . By default it should initialize with a set of 1 instance of Die o The generate_set method should return an Array of the initialized number of dice o It should store the results of generate_set in an instance variable o It should implement a method called dice that returns the generated set stored in the previous step

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions