Skip to content

Instantly share code, notes, and snippets.

@jonathanpike
Created October 15, 2015 13:06
Show Gist options
  • Save jonathanpike/ba8a6221151296c2e7ca to your computer and use it in GitHub Desktop.
Save jonathanpike/ba8a6221151296c2e7ca to your computer and use it in GitHub Desktop.
class Car
attr_accessor :doors, :type, :name
def initialize(doors, type, name)
@doors = doors
@type = type
@name = name
end
def forward
puts "#{@name} drives forward"
end
def reverse
puts "#{@name} reverses"
end
def neutral
puts "#{@name} is in neutral"
end
def inspect_car
puts "#{@name} is a #{@doors} door #{@type}"
end
end
class Tesla < Car
attr_accessor :model
def initialize(doors, type, name, model)
super(doors, type, name)
@model = model
end
def charge
puts "You plug in #{@name}, a Tesla Model #{@model}, and watch it charge. Ah, the sweet taste of savings!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment