- It's time for our first challenge assignment.…This is an opportunity to apply all…that we've learned about classes so far.…In this assignment we're going to model a set of dice…so we're going to have a class for dice set…and when we have an instance of the dice set,…it's going to contain two dice instances…or you can call them die if you prefer.…So, two different models, dice set and dice…and when we call a method on diceset, which is roll…it should roll both of the dice.…
When we roll a dice, of course,…what we are doing is picking a random number…between one and six, it's a six sided dice.…You will recall that in Ruby, we can use rand…with an integer and it will return a random number…from zero up to one less than that integer,…so, rand 6 will give us zero to five…and you would just add one to get one to six.…We should also have another method on dice set…called display that should display the values of both dice.…As you're developing these classes, you can test drive…them in the IRB console, using require relative.…
- Defining a custom class
- Working with instances of a class
- Class and instance attributes and methods
- Class inheritance
- Working with dates and times
- Using modules as namespaces and mixins
- Raising and handling exceptions
Skill Level Beginner
2. Class Attributes and Methods
4. Dates and Times
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.