Created
April 20, 2013 22:40
-
-
Save TalkativeTree/5427703 to your computer and use it in GitHub Desktop.
Review of someone else's code
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 | |
def ==(other) | |
(other.width == self.width && other.height == self.height ) || | |
(other.height == self.width && other.width == self.height ) | |
end | |
end | |
def rectangle_area(ar) | |
area = [] | |
ar.each do | |
area << self.(width * height) | |
end | |
area | |
end | |
def rectangle_perimeter(pm) | |
perim = [] | |
pm.each do | |
perim << self.((width * 2) + (height * 2)) | |
end | |
perim | |
end | |
def rectangle_diagonal(dg) | |
diag = [] | |
dg.each.to_f do | |
diag << self.(Math.sqrt(@width**2 + @height**2)) | |
end | |
diag | |
end | |
def rectangle_square(sq) | |
squr = [] | |
sq.each do | |
if width == height | |
return true | |
else | |
return false | |
end | |
squr | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment