Chapter 04 - Basics of Classes - Exercises

Die Throwing (continued)

Take the "Die Throwing" application from the exercises of chapter 3.

Refactor the code to make use of a class Die. Make sure to add a roll() method to your class.

If you change the number of sides on your die from 6 to 20. Do you need to change your implementation of Die? If so, refactor the class to be independent of the lower and upper limit. You should even be able to create a Die that can generate values from 10 to 16 for example.

results matching ""

    No results matching ""