Question: You are tasked with designing a Python program to model a simple shape hierarchy. A: Define an abstract base class called Shape. This class should:

You are tasked with designing a Python program to model a simple shape hierarchy.
A: Define an abstract base class called Shape. This class should:
Declare an abstract method called area to calculate and return the area of the shape.
Declare an abstract method called perimeter to calculate and return the perimeter of the shape.
Define a common method called display_info that prints the name of the shape.
B: Define three subclasses of Shape for different types of shapes: Circle, Rectangle, and Triangle. Each subclass should:
Inherit from the Shape class.
Implement the area and perimeter methods specific to that type of shape.
Override the display_info method to print the name of the shape (e.g., "Circle", "Rectangle", or "Triangle").
C: Define a class called ShapeManager. This class should:
Have a list called shapes to store instances of different shapes (both Circle, Rectangle, and Triangle).
Implement a method called add_shape that takes a Shape object as a parameter and adds it to the shapes list.
Implement a method called list_shapes that displays the names, areas, and perimeters of all shapes in the shapes list.
Implement a method called total_area that calculates and returns the total area of all shapes in the shapes list.
Implement a method called total_perimeter that calculates and returns the total perimeter of all shapes in the shapes list.
D: Write a sample program that demonstrates the use of your shape hierarchy. Create instances of different shapes, add them to the ShapeManager, list the shapes with their names, areas, and perimeters, and calculate the total area and total perimeter using polymorphism.
Python
 You are tasked with designing a Python program to model a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!