Skip to content

Instantly share code, notes, and snippets.

@jrgifford
Created June 2, 2011 13:57
Show Gist options
  • Save jrgifford/1004485 to your computer and use it in GitHub Desktop.
Save jrgifford/1004485 to your computer and use it in GitHub Desktop.
Test
class Die
def initialize
roll
end
def roll
@numberShowing = 1 + rand(6)
end
def showing
puts "The first dice rolls a " +@numberShowing.to_s
end
def cheat
@numberCheat = '0'
while @numberCheat =! [1..6]
puts 'Enter the number you want to show on the next dice'
@numberCheat = gets.chomp
end
if @numberCheat == [1..6]
puts "You have successfully cheated! \nYou rolled a " + @numberCheat.to_s
end
end
end
puts Die.new.showing
puts Die.new.cheat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment