Created
January 21, 2015 23:20
-
-
Save aguayma/1ee4c98a0f40127d7c66 to your computer and use it in GitHub Desktop.
Help me Jesus
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 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