Assessment Details COIT11222
Assessment item 2 â€“ Java GUI Application
Due date: Midnight, Thursday, 18/09/2014, Week 11 ASSESSMENT
Weighting: 20% 2
Submission: Electronically through Moodle course site
This assessment item is for COIT11222, 2014 Term 2.
This assessment item relates to the course learning outcomes as stated in the Course Profile.
For this assignment, you are required to develop a Java Graphical User Interface (GUI) Application to demonstrate you can use Java constructs including input/output via a GUI, Java primitive and built-in types, Java defined objects, arrays or ArrayLists, selection and looping statements and various other Java commands. Your program must produce the correct results.
The code for the GUI is supplied and is available on the course website. You must complete the underlying code to implement the program. The buttons have been activated and are linked to appropriate methods in the given code. Please spend a bit of time looking at the given code to familiarise yourself with it and where you have to complete the code.
You can create your own GUI if you choose to but DO NOT use any GUI generators.
What to submit for this assignment
1. The Java source code:
If you submit the source code with the incorrect name you will lose marks.
2. A report of your assignment which includes:
a. a UML Activity Diagram (refer to weeks 4 and 5) to depict how your program searched for a car.
b. a short paragraph or 2 about how long it took to create and any problems encountered.
c. screen shots of the output produced. (Use Alt-PrtScrn to capture just the console window and you paste it into your Word document) .
You should test every possibility in the program.
o Your report should be named ReportAss2.docx
You will submit your files by the due date using the â€œAssignment 2â€ link on the Moodle course website under Assessmentâ€¦ Assignment 2 Submission.
You have completed the console program for Motorcity Car Insurance. Your boss now wants a GUI prototype of the program to allow staff to enter details of cars and to produce reports of all the cars in the system. You are to write a Java GUI Application (CarInsuranceGUI class). Most of the GUI code has been written and it looks like this:
The registration of each car is to be entered in to the registration text field.
The age will be selected from the drop down combo box
There is a checkbox for selecting if the car had been in an accident or not.
The pricing structure is the same as assignment 1:
â€¢ Cars over 5 years old will cost $350.00.
â€¢ Cars less than and up till 5 years old will cost $200.00.
â€¢ 25% discount off their insurance cost if there they have not been in an accident before
You will use 4 parallel arrays or ArrayList structures to store the various details about the cars
A maximum of 10 cars should be set.
Your job is to implement the buttons in this program.
The following explains what should happen when each of the buttons are clicked.
When the user hits the enter button the information about the current car will be displayed, for example:
The text area is set to a mono-spaced font (done for you already) so that String.format can be used to align the columns.
To remove the existing content of the text area and input new text: textArea.setText(â€œtext to inputâ€)
To keep the existing content and add new text to the text area: textArea.append(â€œtext to appendâ€)
If the limit of cars is reached, let the user know with an appropriate message dialog:
If no car registration was entered, do not add the details into the program and let the user know with an appropriate message dialog:
After the carâ€™s details have been successfully entered,
â€¢ the registration field must be cleared
â€¢ the combo box returned to zero
â€¢ and the accident check box should be unchecked.
The supplied code returns the focus back to the registration field.
This option will display all cars entered so far and the total of the fees.
This option will sort the cars by registration number and display them.
Hint: You cannot use the inbuilt sort method within Java Arrays class as you will need to sort the four lists in tandem using the registration list as the sort criteria.
When the search button is clicked, use an input dialog box to let the user input the car registration to search for. You can just use a simple linear search. Your search should not be case sensitive (if there is a car with registration â€œHSV123â€, searching with â€œhsv123â€ should be successful).
If the search is successful, display the details about the car.
If the search is unsuccessful, display an appropriate message and clear the text area
When the user selects this option the program will ask the user if they really want to exit the program.
For this use the showConfirmDialog in JOptionPane.
If the user selects â€œYesâ€ (JOptionPane.YES_OPTION), then exit the program, otherwise just ignore and return to the program.
1. Use registrationField.getText() to retrieve the registration of the car
2. Use setText(â€œâ€) to clear the registration field.
3. Use Integer.parseInt((String) ageCombo.getSelectedItem()) to retrieve the car age.
4. Use accidentCheckBox.isSelected() to determine if the accident check box has been selected.
5. Your program should be well laid out, commented and uses appropriate and consistent names (camel notation) for all variables, methods and objects.
6. Make sure you have no repeated code (even drawing the line in the output)
7. You cannot use a list of objects you must use four parallel lists.
8. Constants must be used for all numbers in your code.
9. Look at the marking criteria to ensure you have completed all of the necessary items
10. Refer to a Java reference textbook and the course and lecture material (available on the course web site) for further information about the Java programming topics required to complete this assignment.
11. Check output, check code and add all of your comments, complete report and the UML activity diagram.
Supplied GUI Code
Download, compile and run the supplied GUI code available from the course web site.
You will see the GUI interface has been implemented using the FlowLayout layout manager.
Study the code to understand how it works, you can experiment and change things around, but preserve an original copy of the code for your assignment.
Consider how the interface could be improved using panels and other layout managers.
The window has been adjusted in size so the input area, buttons and output area (text area) line up correctly.
You have to implement the underlying code, use the supplied method stubs and add you own methods.
No code should be repeated in your program.
Good luck! Bernard Li
Course Coordinator (COIT11222 2014 Term2)
Total number of marks â€“ 20
1 Variables, constants and types
Constants are used for all numeric literals 0.5
Variables have meaningful names and use camel notation 0.5
Variables are the correct type and correct access specifiers 0.5
Four parallel lists are used (arrays or ArrayLists) 0.5
Lists are the correct type 0.5
2 Code in general
Code is indented and aligned correctly 0.5
Code is easy to read (use of vertical whitespace) 0.5
Code has header comment which includes name, student ID, date, file name and purpose of the class 0.5
Code is fully commented including all variables and methods 0.5
No repeated code 0.5
Car registration is read correctly 0.5
Age is read correctly 0.5
Accident check box is read correctly 0.5
Fee is calculated correctly 0.5
Data is added to the lists correctly 1
Output resembles the specification 1
Error dialog when maximum cars are reached 0.5
Error dialog when registration not entered 0.5
All GUI fields are returned to default after data is entered 0.5
4 Display All
All records displayed 1
Output resembles the specification 0.5
Total fees is correct 0.5
Sort is correct (zero for using in-built sort) 3
Search is correct and correct details returned 1
Search is case insensitive 0.5
No search result is handled correctly 0.5
User is prompted to exit 0.5
UML activity diagram (flow chart) correct 1
Screen shot(s) of testing 0.5
Report presentation and comments including how long it took and any problems encountered 0.5
Penalty for late submission is 5% per day (1 mark per day) enter negative number
Compilation errors, enter negative number.
Note: If program does not compile and it is a minor error 2 marks will be deducted. Otherwise if the program has major problems the functionality sections (buttons) will receive zero and the rest will be graded upon inspection of the code.
If submitted files do not have the file names specified, deduct 1 mark. Enter negative number.