Answered step by step
Verified Expert Solution
Question
1 Approved Answer
language is python 1. Triangle Class: (35 marks) Design a class named Triangle that extends the given Geometricobject class. The Triangle class contains: Three float
language is python
1. Triangle Class: (35 marks) Design a class named Triangle that extends the given Geometricobject class. The Triangle class contains: Three float data fields named sidel, side2, and side 3 to denote the three sides of the triangle. A constructor that creates a triangle with the specified sidel, side2, and side with default values 1.0. The accessor methods for all three data fields. A method named getArea () that returns the area of this triangle. Amethod named getPerimeter() that returns the perimeter of this triangle. A method named_str_() that returns a string description for the triangle. The formula for computing the area of a triangle is: (side1 + side2 + side 3) 2 s(s - side 1)(s - side 2)(s - side 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. class Geometricobject: def init__(self, color = "green", filled = True): S = area = self. self. color = color filled = filled def getColor (self): return self. color def setColor (self, color): self. color = color def isFilled (self): return self. filled def setFilled (self, filled): self. filled = filled def str__(self): return "color: " + self._color + \ " and filled: + str(self. filled)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started