CPSC120
Fundamentals of Computer Science

In-class Activity 33

  1. Create a Python class called Circle in a file called circle.py that represents a two dimensional circle. Give the class methods that do the following:

    1. Initialize a circle with a location and a radius.
    2. Return a string that represents a circle.
    3. Returns the area of a circle.
    4. Returns whether a circle overlaps with another circle

    In a separate file, create code that tests each of the methods of the circle class.

  2. Modify the Circle class so that when the circle is initialized it also draws a circle at the appropriate location of and appropriate size using turtle graphics. To draw the circle use the shape method to change the appearance of the turtle to a circle. Resize the turtle to the appropriate size using the shapesize method. Note, that the stretch_wid and stretch_len arguments are the factor by which to stretch the turtle’s shape. A factor of 1 will leave the turtle at its orginal size, which is 20 pixels.

  3. Add methods to the Circle class that change the location and radius of the circle. When the location or size of the circle is changed the drawing of the circle should be updated to reflect the change.