In-Class Activity: Object-Oriented Python


Objectives

Your goal for this exercise is to develop a Python class hierarchy to represent shapes in a simple drawing program. Each shape object should maintain sufficient state information to draw itself at the appropriate location using the Python turtle graphics module. The following shapes should be supported as individual classes:

  • Circle
  • Polygon
  • Square
  • Rectangle

You should also think about the following optional shapes and how they might fit into your hierarchy:

  • FilledPolygon
  • FilledCircle
  • Dot

Part 1 - Design

The first step of this exercise is to draw an appropriate UML class hierarchy and determine the member functions and attributes that should be associated with each class. You should look for opportunities to take advantage of inheritance, and consider whether any abstract base classes would be appropriate.

Part 2 - Coding

Once you are satisfied with your class hierarchy, provide a Python implementation (on paper). You don't need to provide the code for the drawing functionality, but you should provide stubs for all methods and implement the constructors.