After reviewing the previous posts, I noticed that many answers did not
incorporate the condition: '...you have to shout BYE three times in a
row...'

This is what I came up with:


puts 'Hey Sonny, it\'s your Grandma! How are you?'

response = nil
bye = 0

while bye < 3
  response = gets.chomp

  if response == 'BYE'
    bye = (bye + 1)

    if bye == 3
      puts 'BYE, SONNY!'
    else
      puts 'HUH?! SPEAK UP, SONNY!'
    end

What do you think?

  elsif response == response.upcase
    puts 'NO! NOT SINCE ' + (1930+rand(21)).to_s + '!'
    bye = 0
  else
    puts 'HUH?! SPEAK UP, SONNY!'
    bye = 0
  end
end

-- 
Posted via http://www.ruby-forum.com/.