COMP106 Assignment 3 – Building a GUI in Java Swing

snottybugbearΛογισμικό & κατασκευή λογ/κού

3 Νοε 2013 (πριν από 4 χρόνια και 6 μήνες)

424 εμφανίσεις

COMP106 Assignment 3 – Building a GUI in Java Swing
The third and final assignment is for you to demonstrate your technical skills in
implementing interfaces in Java Swing. The whole assignment counts for 7% of your
mark for COMP106.
For this assignment you are asked to create a Java Swing GUI to implement a
simple interface for an ATM (Cash Machine).
The interface should contain the following items:
• A text area for displaying the instructions and output for the user’s interactions
with the interface;
• A text area for displaying user input;
• Buttons to enable cash to be withdrawn or deposited, as described below.
• A keypad for entering numbers, along with buttons for the functions ‘clear’ and

This demonstrates a simple example of the required interface.
More usable layouts will attract better marks.

The first thing you should do is implement the GUI as given above, you may choose
the layout yourself (it should conform to good design principles).
Once you have constructed the interface, you should implement the following
functionalities to enable interaction with the GUI:
• When the application starts, the user should enter their PIN
o This should be set to 1234.
o After 3 incorrect attempts the application should exit.
• The user should then be shown their current balance
o This should start at £10.
• The user should then have options to
o Deposit cash
o Withdraw cash (depending on balance)
o Quit (return to the start – the ‘enter pin’ screen)

• If the user chooses to deposit cash.
o The ‘deposit’ cash option should allow the user to enter any integer
cash value less than £1000.
o The balance should be updated.
o A ‘receipt’ for every completed transaction should be printed to the
system console (i.e. using System.out.print) showing the amount
and the new balance.
• The ‘Withdraw’ cash option should have at least the 3 options ‘withdraw £5,
withdraw £10, withdraw £20’.
o These options should only be selectable if the balance is large
o The balance should be updated.
o A ‘receipt’ for every completed transaction should be printed to the
system console showing the amount and the new balance.
• The ‘clear’ button should reset the text area that displays the user input,
giving the user an opportunity to rectify any input mistakes.
The marks for the assignment are based both on the construction of the GUI
and the implementation of its associated functionalities. Marks are also awarded for
code that is well laid out and extensively commented.
The most challenging aspect of the assignment is getting the functionality to work as
If you cannot get your program to work correctly, or completely, still submit
your code.
You will get marks for producing a program that just constructs an interface,
plus any functionality that you have implemented (or even just attempts at
Once you have implemented all the required aspects, you could also add any
features that you deem to be desirable for such a GUI. Marks for the A++ and A+
category will only be awarded to solutions that include such additional features
implemented correctly (in addition to fulfilment of all the other requirements of the
assignment). Such features could include changing the PIN, withdrawing different
cash values or keeping a count of the notes available in the machine.
All your code should be written by hand, without the aid of any interface
construction tools.
Your assignment will be marked in accordance with the following criteria:
• The extent to which the code implements the interface as described.
• The extent to which the code implements the functionalities of the interface as
described, plus any additional functionalities supplied.
• The extent to which the code contains explanatory comments and is well laid
There is set time for you to work on the assignment during the practical classes
where the demonstrators will be available to offer assistance.
Submission instructions:

Make sure that the main executable class is called ‘’ spelt exactly as given
here, so the main class name must also be ‘ATM’. (This is to enable automated
Submit your completed assignment to the department’s electronic submission
system at:

You need to log in to the above system and select ‘COMP106: Human-Centric
Computing’ from the drop-down menu, then follow the instructions for submitting
your work. Make sure that you upload the ‘.java’ file(s).

The deadline for this assignment is Friday 3
May at 3.30pm.

IMPORTANT: Similarity checks will be performed on all submissions. Make sure that
you: do not make use of code from anyone/anywhere else; do not let anyone else
copy any of your code; do not submit ‘jointly developed’ solutions.
Penalties for late submission apply in accordance with departmental policy as set out
in the student handbook, which can be found at: