Lab Assignment 7
CS202, Summer 2006

Please upload your source code files using CSNS. Note that file uploading will be disabled automatically after the lab ends, so please turn in your work on time.

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, make similar changes to the binarySearch method so it works for all classes that implement the Sortable interface. Note that you may not add methods to the Sortable interface, i.e. you'll only have the lessThan method to work with.

2. (5pt) Modify the lessThan method in the Point class such that a point (x1,y1) is "less than" a point (x2,y2) if

Test your new binarySearch method using some Point objects.

3.(10pt) [Simple Calculator, Part I] Write a Java program to show the interface of a simple calculator like the following:

0


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

4.(10pt) [Simple Calculator, Part II] Add event handling such that when a number button is 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.