Abstract Data Types and Java Classes B.Ramamurthy 11/14/2018 B.Ramamurthy
Introduction 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) 11/14/2018 B.Ramamurthy
Topics of Discussion Throttle class : specification, implementation and testing. Packages Location class Specialty: equals method and clone method Examples 11/14/2018 B.Ramamurthy
Throttle Throttle int top; int position; //constructor public Throttle (int size); // accessor method public double getFlow(); //predicate method public boolean isOn(); // service methods public void shift(int amount); public void shutOff(); 11/14/2018 B.Ramamurthy
Location (class) Location class is illustrates two important features that you should implement in your classes; equals method and clone method. 11/14/2018 B.Ramamurthy
Location 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(); 11/14/2018 B.Ramamurthy