Create a Python program that models several geometric shapes from the following class diagram. The diagram represents public, protected and private attributes, as well as inheritance.
Instructions
- Design a base class called
GeometricShape with the properties common to all the shapes, such as the color, and a constructor to initialize them. - Create classes that inherit from
GeometricShape to represent a circle, a square and a triangle. Each one implements the methods that calculate its area and its perimeter. - In the main program, create objects of the different shapes and display their information (color, area and perimeter).
- Notice how inheritance and encapsulation produce more organized and reusable code.
Input and output format. Read, one per line and with no prompts: the color and radius of the circle, the color and side of the square, and the color, base and height of the triangle. Print the three blocks, separated by an empty line, each with the lines Circle Information: / Square Information: / Triangle Information:, Color: …, Area: … and Perimeter: …. Area and perimeter with 2 decimals. The perimeter of the triangle is 3 × base (approximation for an equilateral triangle) and its area base × height / 2.