Lecture 17 Classes and Functions

1. There is a very simple function to calculate the current time
The pass statement is a null operation; nothing happens when it executes. You can delete it if you like.

Now you know the concept of adding more time to the starting time. Let's make this function more complete:
We’ll define a class called Time that records the time of day. The class definition looks like this:

Given the starting time of a movie, and the duration of a movie, the following function will figure out when the movie will be done:

The result, 10:80:00 might not be what you were hoping for. The problem is that this function does not deal with cases where the number of seconds or minutes adds up to more than sixty. When that happens, we have to “carry” the extra seconds into the minute column or the extra minutes into the hour column.

However, what if the movie is pretty long and there are carries in 'hour'.
The same concept, just make the following modification:

2. Prototypoing vs planning
An alternative is designed development, in which high-level insight into the problem can make the programming much easier. In this case, the insight is that a Time object is really a three-digit number in base 60 (see http://en.wikipedia.org/wiki/Sexagesimal.)! The second attribute is the “ones column”, the minute attribute is the “sixties column”, and the hour attribute is the “thirty-six hundreds column”.

We can convert Time objects to integers and take advantage of the fact that the computer knows how to do integer arithmetic.
(Again, the parentheses in 'class Time():' is still redundant)