First Summer 2006


Lab Eight: Software Objects (Chapter 8 in the Python text).

Today's lab will be about the material in Chapter 8 in the Python text.

The lab material and the lab assignment will be posted here shortly.

Lab Assignment
This is your lab assignment for today, Wednesday May 24, 2006:

Write a program to solve the Clock problem.

Write a test program too, that illustrates how your objects are working.

Turn in your programs in OnCourse (under A201-7055) by the end of the day.

Here's an example of what the program might look like:

class Clock(object):
    def __init__(self, time):
        self.hour = int(time[0:2])
        self.minute = int(time[3:])
    def tick(self):
        self.minute = (self.minute + 1) % 60
        if self.minute == 0:
            self.hour = (self.hour + 1) % 24
        self.report()
    def report(self):
        print ("00" + str(self.hour))[-2:] + ":" + ("00" + str(self.minute))[-2:]

clock = Clock("23:58")
clock.tick()
clock.tick()
clock.tick()
clock.tick()
clock.tick()

This problem should be discussed in lab today.

Here are some more problems we could develop:

http://www.cs.indiana.edu/classes/a201-dger/spr2005/notes/007.html
I particularly like the Tigger and Robot problems.

I will post what we do in class today, and I will come to lab for the first half an hour or so.


Last updated: May 22, 2006 by Adrian German for A201/A597