Skip to content

Instantly share code, notes, and snippets.

@Ebeta
Last active August 29, 2015 14:13
Show Gist options
  • Save Ebeta/2b866fb2509b48ec0a1b to your computer and use it in GitHub Desktop.
Save Ebeta/2b866fb2509b48ec0a1b to your computer and use it in GitHub Desktop.
class Quadrilateral
attr_accessor :top, :bottom, :left, :right
def initialize(left, top, right, bottom)
@left = left
@right = right
@bottom = bottom
@top = top
end
def get_perimeter
perimeter = @top+ @bottom + @left + @right
end
end
class Rectangle < Quadrilateral
end
class Square < Rectangle
def area
@right * @top
end
end
class Trapazoid < Quadrilateral
end
class Rhombus < Trapazoid
def rhombus_length
@right
end
end
def test
jeff = Square.new(1,1,1,1)
puts jeff.get_perimeter == 4
puts jeff.area == 1
puts jeff.left == 1
end
test
true
true
true
def test2
greg = Rhombus.new(2,2,2,2)
puts greg.rhombus_length == 2
end
test2
true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment