public
anonymous / test.rb
Created

  • Download Gist
test.rb
Ruby
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 39 40
puts 'Say something nice to Grandma.'
puts 'You may need to shout > '
 
$counter = 0
 
def speaks()
$speak = gets.strip
if $speak != 'Bye'
talk()
else
exitPlan()
end
end
 
def talk()
if $speak == $speak.downcase
puts 'Huh Speak up Sonny'
$counter -= 1
else
year = rand(1930..1951)
puts 'No not Since ' + year.to_s
$counter -= 1
end
if $counter < 0
$counter = 0 # don't want counter going below zero.
end
puts 'Say something nice to Grandma'
speaks()
end
 
def exitPlan()
$counter += 1
unless $counter == 3
puts 'Say something nice to Grandma'
speaks()
else
puts 'good night Sonny'
end
end
speaks()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.