Skip to content

Instantly share code, notes, and snippets.

@aguayma
Created January 21, 2015 23:20
Show Gist options
  • Save aguayma/1ee4c98a0f40127d7c66 to your computer and use it in GitHub Desktop.
Save aguayma/1ee4c98a0f40127d7c66 to your computer and use it in GitHub Desktop.
Help me Jesus
class Quadrilateral
attr_accessor :top, :bottom, :left, :right
def initialize(left, top, right, bottom)
@left = left
@top = top
@right = right
@bottom = bottom
end
#gets the perimeter of the quads
def get_perimeter
perimiter = @left + @top + @right + @bottom
end
end
class Rect < Quadrilateral
def get_area
@left * @top
end
end
class Squa < Rect
def squa_length
@left
end
end
class Trap < Quadrilateral
end
class Rhom < Trap
def rhom_length
@left
end
end
def test
mario = Squa.new(1,1,1,1)
puts mario.get_perimeter == 4
puts mario.get_area == 1
puts mario.squa_length == 1
eric = Rect.new(1,2,2,1)
puts eric.get_perimeter == 6
puts eric.get_area == 2
david = Rhom.new(2,2,2,2)
puts david.get_perimeter == 8
puts david.rhom_length == 2
end
test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment