mardi 5 mai 2015

New Object from Subclass

Lets say I have two classes:

class House
  def initialize(width, height)
      @width = width
      @height = height
  end
end

and:

class BrickHouse < House

end

When I create a House:

house = House.new(33,22)

How can I create a new Brickhouse from this house:

I tried:

 brickhouse = BrickHouse.new(house)

But that didnt worked! What do I wrong? Thanks

Aucun commentaire:

Enregistrer un commentaire