Implement the following class hierarchy inside of a module Solution

Implement the following class hierarchy inside of a module file called polygon.py.

Polygon
Triangle Quadrilateral Pentagon Hexagon Octagon
Isosceles Tri Equilateral Tri Rectangle
Square

Each class should be able to calculate the area and perimeter for an object of that class.

Write another "driver" script called project1.py which imports the polygon.py module, reads an input file of polygonal data and writes another file of areas and perimeters.

Additional notes

All data members should be private and accessed through getters and setters.
Assume that the pentagons, hexagons and octagons are regular.
Assume that the quadrilaterals are cylic.
Do not use the regular polygon area formula for anything but pentagons, hexagons and octagons.
Do not use Brahmagupta's formula for anything but the cyclic quadrilaterals.
Regular polygon constructors should take a single argument for their side length.
The isosceles triangle constructor should take a base and a height.
Other irregular polygon constructors should take an argument for each side.
You should check for nonsensical input, at the very least, check for positive entries.
To open files for reading and writing, review the open function.
To parse the strings in the input file, look at string methods like split.
To read command line arguments, look at the standard sys module and argv.
To write a set number of decimal places, use the string method format.


Powered by