Created
June 2, 2011 13:57
-
-
Save jrgifford/1004485 to your computer and use it in GitHub Desktop.
Test
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 | |
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