2010 March 1 / j d a v i s @ c a r l e t o n . e d u
In this laboratory exercise we continue our study of object-oriented programming. We build on the Particles exercise to perform simulations in which the particles respond to their environment. As was the case with Particles, you must run the code on one of the lab machines. Download these files to your computer.
bopa.pyis our 2D graphics module.
particle.pyis the end product of the Particles exercise.
gravity.pydoes a gravitational simulation.
gravity2.pydoes a gravitational simulation with only two bodies.
zombie.pydoes a zombie infection simulation.
particle.py and read through the code. The code reflects all of the changes described at the end of Particles. I have also added a
gravity.py and read through the code. This is our first example of subclassing. We'll discuss it together.
zombie.py and read through the code. The
Zombie classes have a lot of redundant code. How could we improve the structure of the program, to remove this redundancy?