COMP 142 Project 2: Turtle Snowmen

Assigned: Friday, September 12
Due: Thursday, September 25, 2014 by 11:55pm (on Moodle)

In this project, you are going to use turtle graphics to draw one or more "snow persons." You will define and use at least 7 classes in doing so. Using instances of these classes, you will write a main() function that creates and draws one or more snow people.

Program Description/Specification

  1. Define a minimum of 7 classes. Most can be classes for geometric shapes (e.g. Line, Rectangle, Circle, Triangle), but 3 must be "drawing-specific" classes. (see #4)
  2. Each class will have at least the following methods:
    1. __init__: the constructor will take arguments indicating the positions (coordinate pairs, e.g., (0.0, 0.0)) of one or more referenece points(e.g. start and end points for a line, vertices for a triangle, etc.) and other arguments appropriate for an instance (e.g. pen color, fill color, etc.) To simplify creating instances, it will define appropriate default values for most of the arguments. (If the argument for fill color is the empty string (''), the shape will not be filled.)
    2. __str__: a conversion method, it returns the string to be used for printing an instance in Python.
    3. draw: the draw method will take a turtle.Turtle object to use for drawing the shape.
    4. Other arguments may be required for your methods; all arguments will be described in your comments (see function comments below).
  3. Define a main method that is called without any arguments. Your main function should create and draw one or more snow people at different positions on the canvas.
  4. Define a drawing-specific class hierarchy containing (at least) 3 classes:
    1. Snow_person: an instance contains (at least) 3 snowballs.
    2. Snow_man: specializes a Snow_person with a handful of additional components (e.g. arms, buttons, head wear)
    3. Snow_lady: specializes a Snow_person with an alternate set of additional components.
  5. At a minimum, a snow person should include three snowballs, drawn one on top of the other, and two eyes and a mouth. Feel free to personalize your classes to include other componenents.
Hints: I've included some sample code here: sampleCode.py to show how to use the turtle graphics with your own classes.
The complete turtle graphics Python documentation is available here.

Assignment Notes

The idea is to make classes for geometric objects that you will need in drawing snow people. These objects store information about how they are to be drawn (position, pen and fill color, and such). Invoking the draw function on an object draws it on the canvas at the indicated position and using the indicated colors.

The snow person classes are for making instances of snow people. An instance stores instances of the components (geometric objects) that make up an individual snow person. When creating an instance, you must supply a reference point (coordinate position). You will need to layout the positions for the components relative to this reference point.

As an example of this style of class definition, I supply sampleCode.py. Study this example. Be sure you understand it before proceeding to write your solution. You can use the definitions for the Shape and Line classes in your program (not a requirement). If you do, these count as just one class definition - you will need to write at least another 6 classes. The screen shot below was created by a program that meets the specifications for this project. It shows an instance of a Snow_man class (left) and an instance of a Snow_lady class (right).



Language

You should write this program in Python. If you are still unsure of writing Python code, please come see me so we can discuss options.

Coding style, comments, and pledge

Please see Program 1 for details on proper coding style, comments and including the pledge in your program header.
In particular, every Class you write should have a high-level comment describing what it does, and each of its method functions should have a comments similar to those of regular functions.

What to turn in

Through Moodle, turn in your code as a file called turtleSnow_yourLastName_yourFirstName.py.