Created
June 24, 2015 13:58
-
-
Save jraines/eedf58e3eae3774067d6 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
class Elevator | |
def initialize(floor) | |
@floor = floor | |
end | |
attr_accessor :floor | |
def greet | |
for i in 0..floor | |
if i == 0 | |
puts "Basement." | |
elsif ((i >= 13) && i < floor) | |
puts "Floor #{i + 1}" | |
elsif i == floor | |
puts "You have reached the penthouse" | |
else | |
puts "Floor #{i}" | |
end | |
end | |
end | |
def play_music | |
puts "Would you like to hear some music? Type yes or no." | |
response = gets.chomp | |
if response.upcase == "YES" | |
puts "Muzak playing now..." | |
else | |
puts "Enjoy the silence." | |
end | |
end | |
end | |
otis = Elevator.new(21) | |
otis.greet | |
otis.play_music | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment