-
-
Save unfo/5922361 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Implement a DiceSet Class here: | |
class DiceSet | |
def initialize | |
@noppaluvut = [] | |
end | |
def roll(montako) | |
@noppaluvut = [] | |
# if montako.size == 0 || montako.size > 6 | |
# raise error? | |
# arvo noppaluvut, parametri kertoo montako noppaa? | |
montako.times do | |
@noppaluvut << rand(6) + 1 | |
end | |
@noppaluvut | |
end | |
def values | |
return @noppaluvut | |
end | |
end |
fiksin jälkeen:
irb(main):023:0> dc = DiceSet.new
=> #<DiceSet:0x7f83000fdd38 @noppaluvut=[]>
irb(main):024:0> dc.roll(10)
=> [3, 2, 3, 5, 6, 1, 1, 1, 6, 2]
irb(main):025:0> dc.roll(10)
=> [3, 1, 2, 6, 3, 2, 2, 3, 4, 6]
irb(main):026:0> dc.roll(10)
=> [6, 1, 4, 1, 5, 3, 5, 1, 4, 2]
irb(main):027:0> dc.roll(10)
=> [1, 6, 3, 1, 3, 6, 2, 6, 6, 5]
irb(main):028:0> dc.roll(10)
=> [2, 5, 5, 5, 1, 6, 4, 1, 1, 1]
irb(main):029:0> dc.roll(10)
=> [2, 6, 1, 5, 6, 1, 4, 5, 5, 5]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ennen tota +1 randille :
irb(main):023:0> dc = DiceSet.new
=> #<DiceSet:0x7fb7c72a04f0 @noppaluvut=[]>
irb(main):024:0> dc.roll(2)
=> [3, 2]
irb(main):025:0> dc.values
=> [3, 2]
irb(main):026:0> dc.roll(5)
=> [4, 4, 2, 2, 0]