Created
January 24, 2013 05:33
-
-
Save mfpiccolo/4617922 to your computer and use it in GitHub Desktop.
my_dice.roll will give you a random number from one to six. to change the number of sides change the argument in Die.new()
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 :sides | |
def initialize(number) | |
@number = number | |
end | |
def roll | |
rand(1..@number) | |
end | |
end | |
my_dice = Die.new(6) | |
puts my_dice.roll |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment