Abstract Data Types and Java Classes B Ramamurthy

Abstract Data Types and Java Classes B. Ramamurthy 1/9/2022 B. Ramamurthy 1

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) 1/9/2022 B. Ramamurthy 2

Topics of Discussion Throttle class : specification, implementation and testing. Packages Location class n Specialty: equals method and clone method Examples 1/9/2022 B. Ramamurthy 3

Throttle int top; int position; //constructor public Throttle (int size); // accessor method public double get. Flow(); //predicate method public boolean is. On(); // service methods public void shift(int amount); public void shut. Off(); 1/9/2022 B. Ramamurthy 4

Location (class) Location class is illustrates two important features that you should implement in your classes; equals method and clone method. 1/9/2022 B. Ramamurthy 5

Location double x; double y; Location (double x. Init, double y. Init); Object clone(); static double distance (Location p 1, Location p 2); boolean equals(Object obj); double get. X(); double get. Y(); static Location mid. Point(Location P 1, Location p 2); void rotate 90(); void shift(double x. Amt, double y. Amt); String to. String(); 1/9/2022 B. Ramamurthy 6
- Slides: 6