Title: Abstract Data Types and Java Classes
1Abstract Data Types and Java Classes
2Introduction
- Last class we developed a Rectangle interface and
an implementation for it. - We will examine some more standard methods to be
added to a class. - Also look into creating packages.
- Your assignment Study the Throttle class
defined in your text pages 36-56, esp. p.45,46
(design and code)
3Topics of Discussion
- Throttle class specification, implementation
and testing. - Packages
- Location class
- Specialty equals method and clone method
- Examples
4Throttle
Throttle
int top int position
//constructor public Throttle (int size) //
accessor method public double getFlow() //predic
ate method public boolean isOn() // service
methods public void shift(int amount) public
void shutOff()
5Location (class)
- Location class is illustrates two important
features that you should implement in your
classes equals method and clone method.
6Location
Location
double x double y
Location (double xInit, double yInit) Object
clone() static double distance (Location p1,
Location p2) boolean equals(Object obj) double
getX() double getY() static Location
midPoint(Location P1, Location p2) void
rotate90() void shift(double xAmt, double
yAmt) String toString()