CSC111 Homework 11

From dftwiki3
Revision as of 08:00, 15 April 2010 by Thiebaut (talk | contribs)
Jump to: navigation, search



This homework assignment is due next Thursday, at midnight. It deals with Object Oriented Programming, classes, and objects. The optional part deals classes containing lists of objects.

Bubbles, bubbles, bubbles

  • Write a program that is called hw11a.py, that is the continuation of Lab 11.
  • Your program should have a class for a fish, as you did in Lab 11.
  • In the new program you need implement a new type of object which represents bubbles. A bubble is an object for which you have to declare a new class. One bubble = one object.
  • As fish move around they generate bubbles through their mouth. In other words, bubble will appear randomly and when they do, their center should be the mouth of the fish (or close to it). Then, as the simulation goes on, the fish moves slowly forward, and the bubble moves slowly upward.
  • When a fish disappear from the tank, because it moves out, it should reappear on the other side of the tank. Make sure this operation is life-like, i.e. we want to see the nose of the fish appear, then its head, then its body, then it's fully on the graphics window.
  • When a bubble disappear from the tank, it is removed from the simulation. You will very likely use a list to keep track of the bubbles, and as a bubble leaves the tank completely, it should be removed from the list.

Optional and Extra-Credit

  • Create a new class called School, which will contain the list of fish currently in the tank, and the list of bubbles.
  • You are free to decide how the simulation (main loop where the object moves) is implemented:
    • Either you create a function called by main() that contains a loop that moves the fish and the bubble, or
    • The School class contains a method that runs the simulation, moving all the fish and the bubble around.
  • If you do this program, call it hw11b.py.

Submission

 submit hw11a.py

and/or

 submit hw11b.py            (if you have done the extra credit question)