Triangle Class Design Class Named Triangle Extends Geometricobject Class Triangle Class Co Q37141709

(The Triangle class)

Design a class named Triangle that extends the GeometricObjectclass. The Triangle class contains:

– Three float data fields named side1, side2, and side3 todenote 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 methods for all three data fields.
– A method named getArea() that returns the area of thistriangle.
– A method named getPerimeter() that returns the perimeter of thistriangle.
– A method named __str__() that returns a string description forthe triangle.

For the formula to compute the area of a triangle, see Exercise2.14. The __str__() method

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.