Everything you need to know to complete today's activity is covered in appendix D of our textbook. The section on Classes in the Python tutorial is also quite clear.
main
function
for testing the Classes that you will create below. Don't forget to
include a call to main
.
xPos(): float
indicates that
the xPos
method will return a floating point
number. contains(x:float,y:float): boolean
indicates that the contains
method expects two
floating-point parameters and returns a boolean.
xPos
and yPos
functions return
the of the lower-left corner of a rectangle, and the center
of a circle.
super(SubClassName,self).__init__(args)Where
SubClassName
is the name of the subclass, and args
represents the arguments expected by the constructor of the
superclass (excluding self
).
>>> c = Circle(0.0, 0.0, 50.0, "red") >>> c.draw() red Circle with radius 50.0 drawn at position (0.0, 0.0).
There is nothing to hand in for this assignment. Make sure that you save a copy of your code, either on a thumb drive, the N: drive, or by e-mailing it to yourself. If you worked with a partner, make sure both of you get a copy.