Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming 2 LAB TA: Nouf Al-Harbi NoufNaief.net :::

Similar presentations


Presentation on theme: "Programming 2 LAB TA: Nouf Al-Harbi NoufNaief.net :::"— Presentation transcript:

1 Programming 2 LAB TA: Nouf Al-Harbi NoufNaief.net ::: nouf200@hotmail.com

2 Abstract Class & Interface Quick Review

3 Abstract Class vs. Intrface

4 The Comparable InterfaceThe Comparable Interface The compareTo method determines the order of this object with the specified object o and returns a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than o. // This interface is defined in // java. lang package package java.lang; public interface Comparable { public int compareTo(Object o);} public int compareTo(Object o);} o

5 Program: Enabling GeometricObject comparable Problem Description: Modify the GeometricObject class to implement the Comparable interface. Define a static max method in the GeometricObject class for finding the larger of two GeometricObject objects. Write a test program that uses the max method to find the larger of two circles and the larger of two rectangles.

6 GeometricObject Class

7 Circle Class

8 Main Class


Download ppt "Programming 2 LAB TA: Nouf Al-Harbi NoufNaief.net :::"

Similar presentations


Ads by Google