Presentation is loading. Please wait.

Presentation is loading. Please wait.

Abstract Data Types and Java Classes

Similar presentations


Presentation on theme: "Abstract Data Types and Java Classes"— Presentation transcript:

1 Abstract Data Types and Java Classes
B.Ramamurthy 11/14/2018 B.Ramamurthy

2 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

3 Topics of Discussion Throttle class : specification, implementation and testing. Packages Location class Specialty: equals method and clone method Examples 11/14/2018 B.Ramamurthy

4 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

5 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

6 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


Download ppt "Abstract Data Types and Java Classes"

Similar presentations


Ads by Google