Notes
Outline
Review
View classes as modules
Encapsulate operations
functions are static methods
View classes as struct types
Encapsulate data
View Classes as Abstract Data Types (ADT)
ADT = (V,O)
V: a set of values
O: a set of operators
Information hiding, encapsulation, modularity
An Integer Class (Int)
Using the Class Int
A Rectangle Class
Using the Class Rectangle
A Stack Class
Exercises
Add the following methods to the class Rectangle.
int area()
return the area of the rectangle
boolean isSquare()
test whether the rectangle is a square
Define the class Queue by modifying the class Stack.