Last active
December 29, 2015 06:48
-
-
Save vanmichael/7631070 to your computer and use it in GitHub Desktop.
Phase 3
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
| #Echo Phase 3 | |
| class Echo | |
| def initialize | |
| get_input | |
| if @input == "Nothing!" | |
| puts "Ok, fine!" | |
| elsif @input == "I have a lot to say" | |
| respond_to_alot | |
| else | |
| play_back(@input) | |
| end | |
| end | |
| def get_input | |
| puts "What do you want to say?" | |
| @input = gets.chomp | |
| end | |
| def play_back(response) | |
| puts "You said: #{response}" | |
| end | |
| def respond_to_alot | |
| puts "Ok, Let's hear it!" | |
| comments = [] | |
| while @input != "done" | |
| @input = gets.chomp | |
| comments << @input if @input != "done" | |
| end | |
| comments.each do |comment| | |
| puts "You said: #{comment}" if comment == comments.first | |
| puts "Then, you said: #{comment}" if comment != comments.first && comment != comments.last | |
| puts "Finally, you said: #{comment}" if comment == comments.last | |
| end | |
| puts "Phew! Glad you got all #{comments.length} of those things off your chest!" | |
| end | |
| end | |
| Echo.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment