CM610 - Application Integration - Practical 1
ndI recommend especially Java Precisely, 2 Edition by Peter Sestoft (MIT Press, 2005): a very short,
cheap (~?12) up-to-date (Java 5) reference.
Other Java textbooks I have found useful are:
thththDeitel, H M & Deitel, P J: Java - How to Program: 6 Edition 2004, 5 Edition 2003, 4 edition, rd2002, 3 Edition 1999 are all suitable as a basic Java book. This book is expensive but has lots of
examples on a wide range of Java topics.
Flanagan, David, Java in a Nutshell, O'Reilly [Also companion volumes eg Java Examples in a
Nutshell, Java Foundation Classes in a Nutshell]
Y Daniel Liang, Introduction to Java Programming (6th ed), Pearson
The java website: Convenient look-up reference on classes is at
and links to good tutorial material are to be found at
For a Quick Reminder of Basic Java
(or a quick introduction if your first language is not Java) try the “programming taster
activities” at http://computing.unn.ac.uk/staff/cgmb3/programmes.html
1. Investigate the integer sorting examples:
(a) How long do the SortExpt and the SortExpt2 take to sort 10000 numbers? 100000? more?
(b) What happens to this performance if you replace the quick-sort method in SortExpt2 with
the selection sort algorithm used in Sorter.java, Sorter2.java?
(c) How does it perform using the bubble-sort -
1.Pass through the array comparing pairs of adjacent entries. Swap any pairs that are out of order.
This flushes the biggest entry to the end. It rises to the top like a bubble -- get it?. Note where in
the array the last swap occurred. All entries from here on are in the right place.
2. Repeat this process, just as far as 1 before the place just noted, swapping adjacent entries that
are out of order and noting where in the array the last swap occurs. Repeat until you get a pass in
which there are no swaps.
(d) Develop a program which sorts Strings in alphabetic order.
2. Develop a recursive function to compute the factorial of an integer number: fact(0) = 1, fact(1) = 1, fact(2) = 1x2, fact(3) = 1x2x3, etc.
51282877.doc 1 24/04/2010 13:05:00
3. Adapt the arithmetic quiz so that, like Mastermind, it asks the user questions for one minute, then finishes, telling the user her score. You could develop the quiz timer using the
method System.currentTimeMillis() to report the time on the system clock.
4. Write a main class for the Bank example: a class with a main( ) which creates a Bank with
several Accounts, and performs some transactions on them. Test the Bank, Account and
InterestBearingAccount methods as thoroughly as you can.
5. Develop a graphical user interface for the Bank example.
6. Develop a graphical user interface for the arithmetic quiz(zes).
7. Develop a graphical stop-clock, with buttons to start, stop and reset the timer, and freeze
(and unfreeze) the display (with the timer still running). Explore the different varieties of
button that might be used.
8. Develop a timer that can count down, like an egg timer. You might try to integrate this
with number 7 above – a single timer that can operate in two modes.
9. Upgrade the 0s and Xs example so that it offers to play several games and keeps score.
10. Write an application that accepts a user ID and a PIN, does a look-up in a disk file of
user-IDs and PINs, and reports either (a) that the user-ID was found and the submitted PIN
was valid; or (b) the user-ID was found and the submitted PIN was INvalid; or (c) the user-
ID was NOT found in the file.
11. Upgrade the Mastermind arithmetic quiz so that it maintains a file on disk of players and
51282877.doc 2 24/04/2010 13:05:00