Created
October 15, 2015 13:06
-
-
Save jonathanpike/ba8a6221151296c2e7ca to your computer and use it in GitHub Desktop.
This file contains 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 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