Skip to content

Instantly share code, notes, and snippets.

@FrancoB411
Created May 19, 2011 05:07
Show Gist options
  • Select an option

  • Save FrancoB411/980228 to your computer and use it in GitHub Desktop.

Select an option

Save FrancoB411/980228 to your computer and use it in GitHub Desktop.
Piano
class Piano
attr_accessor :brand, :age, :power
def initialize
@brand = "steinway"
@age = 10
@power = 0
end
def self.instrument_type
"piano"
end
def enter_instruction
puts "command me"
@i = gets
play_piano if @i == "\"play\"\n"
end
def off
if @power == 1
@power = 0
puts "The Piano is off now."
elsif @power == 0
puts "try turning it on first Einstein"
end
end
def on
@power = 1
puts "Piano is on."
enter_instruction
end
def play_piano
puts "I'm playing a song, dum dee dum."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment