On Fri, 31 Mar 2006 10:22:03 -0500, Jan_K <non / none.com> wrote:

>On Thu, 30 Mar 2006 22:53:30 GMT, "Dave Burt" <dave / burt.id.au> wrote:
>
>You're right, I didn't implement one of the features after reading the
>exercise instructions again. Oh well. I'll do it tomorrow.
>
>But I just ran your solution and it doesn't work  :)
>
>
>>Hello Grandma
>HUH!? SPEAK UP, SONNY!
>>HELLO GRANDMA
>NO, NOT SINCE 1938!
>>BYE
>NO, NOT SINCE 1941!
>>BYE
>NO, NOT SINCE 1945!
>>BYE
>NO, NOT SINCE 1941!
>>BYE
>BYE, BYE
>
>
>I needed 4 BYE's to get out, not 3.

Here's the fix:


byes = 0

until byes == 3
  input = gets.chomp
  
  if input == "BYE"
    byes = byes + 1
  else
    byes = 0
  end
  if input == input.upcase
    puts "NO, NOT SINCE " + (1930 + rand(21)).to_s + "!"
  else
    puts "HUH!? SPEAK UP, SONNY!"
  end
end
puts "BYE, BYE"