-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchap_06_d.rb
35 lines (31 loc) · 798 Bytes
/
chap_06_d.rb
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
=begin
Extend your Deaf Grandma program: What if grandma doesn't want you to leave?
When you shout BYE, she could pretend not to hear you. Change your previous
program so that you have to shout BYE three times in a row. Make sure to test
your program: if you shout BYE three times, but not in a row, you should still
be talking to grandma.
=end
byes = 0
comment = gets.chomp
ended = 0
while ended != 1
if comment != "BYE"
if comment != comment.upcase
puts "HUH?! SPEAK UP, SONNY!"
byes = 0
comment = gets.chomp
else
puts "NO, NOT SINCE " + (1930 + rand(21)).to_s + "!"
comment = gets.chomp
byes = 0
end
else
byes += 1
if byes != 3
puts "HUH?! SPEAK UP, SONNY!"
comment = gets.chomp
else
exit
end
end
end