Skip to content

Instantly share code, notes, and snippets.

@clark-teeple
Forked from davidvandusen/shakil_the_dog.rb
Last active August 29, 2015 14:28
Show Gist options
  • Save clark-teeple/20f4fd55204c1fbfde3e to your computer and use it in GitHub Desktop.
Save clark-teeple/20f4fd55204c1fbfde3e to your computer and use it in GitHub Desktop.
#I had a 24 line version, but the assignment seems to request more than one method.
go = true
while go
#could be a method, but really no need to
#since it always has to happen
puts "> "
speak = gets.chomp.downcase
#had this in the main method, but this works too
def continue(speak)
if speak == "go away"
go = false
else
go = true
end
return go
end
#party
def shakil_the_dog(speak)
response = nil
if speak == "woof"
response = "WOOF WOOF WOOF"
elsif speak == "shakil stop"
response = " "
elsif speak == "meow"
response = "woof woof woof woof woof"
elsif speak.include? "treat"
response = "............."
else
response = "*Shakil does not understand*"
end
puts response
end
#done?
go = continue(speak)
#nope!
if go == true
shakil_the_dog(speak)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment