Lab Assignment 6
CS202, Summer 2004


1.(5pt) We showed in the lecture that the bubbleSort method can be made more "general" to handle objects of different classes. For this exercise, write an interface Comparable2 (or an abstract class Comparable2), and make changes to the binarySearch method such that the method works for all classes that implement the Comparable2 interface (or inherits from the Comparable2 abstract class).

2.(5pt) Make necessary changes to the Point class, and use it to test your improved binarySearch method. In particular, when comparing two points (x1,y1) and (x2,y2),
3.(5pt) [Simple Calculator, Part I] Write a Java program to show the interface of a simple calculator like the following:

7.32


Backspace
C
7
8
9
/
sqrt
4
5
6
*
x^2
1
2
3
-
1/x
0
+/-
.
+
=

4.(5pt) [Simple Calculator, Part II] Add event handing such that when the number buttons are clicked, the number shows up in the display area at the top of the calculator, and when the Clear (C) button is clicked, previous number is cleared and the display area shows 0.