Skip to content

Instantly share code, notes, and snippets.

@jraines
Created June 24, 2015 13:58
Show Gist options
  • Save jraines/eedf58e3eae3774067d6 to your computer and use it in GitHub Desktop.
Save jraines/eedf58e3eae3774067d6 to your computer and use it in GitHub Desktop.
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