-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDice.rb
More file actions
38 lines (32 loc) · 675 Bytes
/
Dice.rb
File metadata and controls
38 lines (32 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Die
def initialize
# I'll just roll the die, though we
# could do something else if we wanted
# to, like setting the die with 6 showing.
roll
end
def roll
@numberShowing = 1 + rand(6)
end
def showing
@numberShowing
end
def cheat
@side = {}
if (@numberShowing == 1)
p @side["one"] = 1
elsif (@numberShowing == 2)
p @side["two"] = 2
elsif (@numberShowing == 3)
p @side["three"] = 3
elsif (@numberShowing == 4)
p @side["four"] = 4
elsif (@numberShowing == 5)
p @side["five"] = 5
else
p @side["six"] = 6
end
end
end
puts Die.new.showing
puts Die.new.cheat