Object Oriented Programming Language

A programming language which allows the modelling of object interaction. Java and Python are OO programming languages. Typically an OO programming language supports: OO Programming Languages encourage code reuse, capturing of concepts.

References

Using Objects

Our goals...

Exercise: Balloon

A Balloon IS-A: (later) HAS-A: amount - the amount of air in the Balloon capacity - the maximum amount of air the Balloon can hold popped - True/False (whether this Balloon is popped or not) RESPONDS-TO: __init__ - the constructor, when we create a new Balloon inflate(amount) - add amount to self if self is not popped, possibly popping self deflate(amount) - remove amount from self if self is not popped __str__ - obtain a string representation of self Note: By consistent state in this case, we mean, at all times 0<=self.amount<=self.capacity Once a balloon is popped, it can not be inflated Balloon.py is our start at implementing the class Balloon.

Exercise: JugPuzzle

Our goal will be to write a program which will allow a user to play the Jug puzzle.

Introduction to UML

Exercises

Inheritence and Polymorphism

Examples