Skip to content
Create a gist now

Instantly share code, notes, and snippets.

anonymous /test.rb
Created

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.