Live coding today! We will design and implement classes for various animals (
Animal
,
Fish
,
Bird
,
Penguin
, and
Parrot
). What is an appropriate hierachy? What class and instance attributes do we need? Can we have default values for some attributes? What methods do we need and which ones should we override?
Slides: individual slides for viewing , 6-up layout for printing
Examples:
Parrot
and
Penguin
are for
you
to implement)
Complete the file
zoology.py
by implementing the subclasses
Parrot
and
Penguin
. You can design them as you wish--this is just for practice--but you can use the ideas below if you want to match your code to ours, which
is now
posted
:
Parrot
speak
) it
always
asks for a cracker ("Now give me a cracker!")
Penguin
After you complete the class definitions, check out this
module that sets up a zoo
! The given module creates a
Zoo
and lets you interact with the animals. You can play a little at the zoo, and then read the code to see how we use
Animal
and its subclasses.