Created
November 25, 2013 14:39
-
-
Save justuseapen/7642158 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "What would you like to say?" | |
phrase = gets.chomp | |
def lots_to_say | |
phrases = [] | |
puts "Ok, let's hear it!" | |
input = "" | |
while input != "done" | |
input = gets.chomp | |
if input == "done" | |
break | |
else | |
phrases << input | |
end | |
end | |
phrases.each do |phrase| | |
if phrase == phrases[0] | |
puts "You said: #{phrase}" | |
elsif phrase == phrases.last | |
puts "Finally you said: #{phrases.last}" | |
else | |
puts "Then, you said: #{phrase}" | |
end | |
end | |
puts "Phew! I'm glad you got all #{phrases.length} of those things off your chest!" | |
end | |
def speech | |
puts "Ok. Where can I find what you want to say?" | |
location = gets.chomp | |
puts "Loading #{location}" | |
lines = [] | |
File.readlines("#{location}").each do |line| | |
lines << line | |
end | |
lines.each do |line| | |
if line == lines[0] | |
puts "You said: #{line}" | |
elsif line == lines.last | |
puts "Finally you said: #{lines.last}" | |
else | |
puts "Then, you said: #{line}" | |
end | |
end | |
end | |
def playback(phrase) | |
if phrase == "Nothing!" | |
puts "OK, fine!" | |
elsif phrase == "I have a lot to say." | |
lots_to_say | |
elsif phrase == "I have something prepared." | |
speech | |
else | |
puts "You said: #{phrase}" | |
end | |
end | |
playback(phrase) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment