Skip to content

Instantly share code, notes, and snippets.

@TrevMcKendrick
Created October 11, 2013 15:58
Show Gist options
  • Save TrevMcKendrick/6937308 to your computer and use it in GitHub Desktop.
Save TrevMcKendrick/6937308 to your computer and use it in GitHub Desktop.
class Triangle
attr_accessor :side_a, :side_b, :side_c
def initialize(side_a, side_b, side_c)
@side_a = side_a
@side_b = side_b
@side_c = side_c
puts 2
end
def kind
puts 1
if self.side_a == self.side_b && self.side_b == self.side_c
puts "hi"
return :equilateral
end
if self.side_a == self.side_b || self.side_b == self.side_c || self.side_a == self.side_c
return :isosceles
end
if self.side_a + self.side_b < self.side_c || self.side_a + self.side_c < self.side_b || self.side_b + self.side_c < self.side_a
raise :TriangleError
end
return :scalene
end
end
t = Triangle.new(2,2,2)
puts t.kind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment