For this project, you will write most of the code, but it will be in only two files, and you will have comments as a guide. When you actually run the program, it will print off information about a group of shapes -- circles, triangles, and rectangles. This will be accomplished with three files:
- shape_types.py:
- This file will contain code for three class definitions: Rectangle, Circle, and Triangle
- Each class will have certain attributes:
- A Circle will have a radius.
- A Rectangle will have a length and width.
- A Triangle will have three side lengths.
- Each class will have a constructor that sets up information about a shape's attributes
- Each class will have a string method (def __str__(self):) that produces a string with information about the shape's dimensions. (See sample output.)
- Circle and Rectangle will have getters and setters for their attributes. The setters will verify that the new attribute values are both greater than zero.
- Triangle will have neither a getter nor a setter.
- Each class will have an area() method that calculates the area appropriately
- shape_cli.py will:
- Read and execute the code from shape_types.py
- Create an empty list
- Read in data from shapes.dat (as tuples) to create Rectangle, Circle, and Triangle objects -- and append them to the list
- Print out the different information about the shapes
- (Some steps are not spelled out explicitly here, but they are still necessary.)
- shapes.dat will:
- Contains a series of (pickled) tuples of information about a shape's dimensions.
- Terminates with a value of None.
- The length of the tuple is your clue as to which shape is intended:
- A tuple of length 1 indicates a Circle, where the single value is the radius.
- A tuple of length 2 indicates a Rectangle, where the two values are the length and width.
- A tuple of length 3 indicates a Triangle, where the three values is are the three side lengths.
- This file is there for your testing purposes, and you do not need to upload it because I will use a different data file when grading.
- You should not alter this file in any way, though you may wish to create your own separate data file for extra testing.
Some additional points of consideration: