Created
May 29, 2013 03:00
-
-
Save markson/5667686 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 Rectangle | |
attr_accessor :width, :height | |
def initialize(width, height) | |
@width = width | |
@height = height | |
end | |
end | |
class Square < Rectangle | |
def initialize(length) | |
super(length, length) | |
end | |
def width=(number) | |
super(number) | |
@height = number | |
end | |
def height=(number) | |
super(number) | |
@width = number | |
end | |
end | |
s = Square.new(100) | |
s.width = 50 | |
puts s.height |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment