|
class GeometricObject:
def __init__(self, color, filled):
self.color = color
self.filled = filled
class Triangle(GeometricObject):
def __init__(self, side1, side2, side3, color, filled):
super().__init__(color, filled)
self.side1 = side1
self.side2 = side2
self.side3 = side3
def get_area(self):
s = (self.side1 + self.side2 + self.side3) / 2
return (s * (s - self.side1) * (s - self.side2) * (s - self.side3)) ** 0.5
def get_perimeter(self):
return self.side1 + self.side2 + self.side3
def __str__(self):
return f"{self.side1} {self.side2} {self.side3} {self.color} {self.filled}"
side1, side2, side3, color, filled = input().split()
filled = True if filled.lower() == 'true' else False
triangle = Triangle(float(side1), float(side2), float(side3), color, filled)
print(triangle)
print(f"{triangle.get_area():.2f}")
print(f"{triangle.get_perimeter():.2f}")
|
|