Home / Expert Answers / Computer Science / nbsp-in-pyhton-please-with-the-screenshot-of-the-codes-design-a-class-named-triangle-that-extends-pa888

(Solved):  in pyhton please with the screenshot of the codes Design a class named Triangle that extends ...



Design a class named Triangle that extends the Geometricobject class given in the textbook. The Triangle class contains:
- Th in pyhton please with the screenshot of the codes

Design a class named Triangle that extends the Geometricobject class given in the textbook. The Triangle class contains: - Three float data fields named side1, side2, and side3 to denote the three sides of the triangle. - A constructor that creates a triangle with the specified side1, side2, and side3 with default values \( 1.0 \). - The accessor (getter) and mutator (setter) methods for all three data fields. - The class should throw a RuntimeError exception if the three given sides cannot form a triangle (If one of sides is 0 or less than 0. .) - A method named getArea() that returns the area of this triangle. - A method named getPerimeter() that returns the perimeter of this triangle. - A method named _eq_(self, other) that checks whether two triangles are equal of not by comparing their three sides. For example, if a triangle has side lengths \( 4,1,3 \) and another one has side lengths \( 3,4,1 \) then they should be accepted equal. - A method named __str__() that returns a string description for the triangle. The __str_[] method is implemented as follows: retum "Triangle: side \( 1={ }^{*}+\operatorname{str}( \) side 1\( )+ \) side \( 2= \) " \( + \) \( \operatorname{str}( \) side 2\( )+ \) " side \( 3= \) " \( +\operatorname{str}(\operatorname{sid} z 3) \) Implement the Triangle class. Write a test program that prompts the user to enter the three sides of the triangle, a color, and 1 or 0 to indicate whether the triangle is filled. The program should create a Triangle object with these sides and set the color and filled properties using the input. The program should display the triangle's area, perimeter, color, and True or False to indicate whether the triangle is filled or not.


We have an Answer from Expert

View Expert Answer

Expert Answer


Here is the implementation of the Triangle class: from math import sqrt classTriangle(GeometricObject): def__init__(self, side1=1.0, side2=1.0, side3=
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe