Created
September 3, 2012 22:52
-
-
Save abrongersma/3614373 to your computer and use it in GitHub Desktop.
Die.class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Die | |
attr_accessor :faces | |
def initialize(faces) | |
@faces = faces | |
end | |
def sides | |
@faces | |
end | |
def roll | |
(1..@faces).to_a.sample | |
end | |
end | |
my_die = Die.new(6) | |
puts my_die.roll |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment