In Class: Week 12 Tuesday and Thursday:
Defining Classes


Create a week12 subdirectory in your cs21/class directory by running update21:

$ update21
$ cd
$ cd cs21/class/week12

Topics


In-class work

    Classes

  1. Open up accounts.py. Read through the mostly completed class definition for a bank account. Using this class will be able to define Account objects.

  2. First, we will illustrate the use of several functions. You should be able to draw a stack diagram for the constructor showing how self is defined.

  3. Open up testAccounts.py and trace the code which creates three separate Account objects using the constructor, prints them using the string conversion method, and prints out information given by the accessor methods getBalance and getName

  4. Take some time to implement and test the changePin method. It is very important that you employ unit testing just as you did with the top-down design labs

  5. When you are finished, analyze and test the withdraw() function. Once you understand how that works, implement and test the deposit() method. If you have time, implement and test the computeInterest() method.

  6. In song.py, begin implementing a Song class from scratch. This class should define the necessary data to describe a Song on your computer (e.g., and MP3). This includes such data as title, artist, album, length, file name, etc. Also define the necessary methods, including getters and setters, to manipulate the object. Be sure to test our your methods one-by-one in your testSong.py program.