Created
May 28, 2013 21:55
-
-
Save markson/5666484 to your computer and use it in GitHub Desktop.
composition
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
require 'pry' | |
class Car | |
attr_reader :model, :valve | |
attr_writer :passenger | |
def initialize(model, valve) | |
@model = model | |
@engine = Engine.new(valve) | |
end | |
def run | |
puts "wowowowo" | |
end | |
end | |
class Engine | |
def initialize(valve) | |
@valve = valve | |
end | |
end | |
class Passenger | |
def initialize(name) | |
@name = name | |
end | |
end | |
p = Passenger.new("Foo") | |
car = Car.new("9-3 convertible", 4) | |
car.passenger(p) | |
binding.pry | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment