






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







class Time(object): """Instances represent times of day. Instance variables: hour [int]: hour of day, in 0..23" min [int]: minute of hour, in 0.. """ def init(self, hour, min): """The time hour:min." Pre: hour in 0..23; min in 0..59""" def increment(self, hours, mins): """Move this time
class Rectangle(object): """Instances represent rectangular" regions of the plane. Instance variables: t [float]: y coordinate of top edge" l [float]: x coordinate of left edge" b [float]: y coordinate of bottom edge" r [float]: x coordinate of right edge For all Rectangles, l <= r and b <= t. """ def init(self, t, l, b, r): """The rectangle [l, r] x [t, b] Pre: args are floats; l <= r; b <= t""" def area(self): """Return: area of the rectangle.""" def intersection(self, other): """Return: new Rectangle describing intersection of self with other.""" class invariant States what attributes are present and what values they can have. A statement that will always be true of Rectangle instances. method specification States what the method does. Gives preconditions stating what is assumed to be true of the arguments.
Instance variables: hour [int]: hour of day, in 0..23" min [int]: minute of hour, in 0..
def init(self, hour, min): """The time hour:min." Pre: hour in 0..23; min in 0..59"""
self.hour = hour self.min = min
Ā§ļ§ interface between two programmers Ā§ļ§ interface between two parts of the program