|
|
|
|
View classes as modules |
|
Encapsulate operations |
|
functions are static methods |
|
View classes as struct types |
|
Encapsulate data |
|
|
|
|
|
|
|
ADT = (V,O) |
|
V: a set of values |
|
O: a set of operators |
|
Information hiding, encapsulation, modularity |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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. |
|