COIT 11222: JAVA Program – Windowed GUI Java Program – Java Assignment Help

Responsive Centered Red Button

Need Help with this Question or something similar to this? We got you! Just fill out the order form (follow the link below), and your paper will be assigned to an expert to help you ASAP.

Internal Code: 1ABCGJ
Java Assignment Help
Task: 
For this assignment, you are required to develop a
Windowed GUI Java Program
to demonstrate you can use Java constructs including input/output via a GUI interface, Java primitive and built-in types, Java defined objects, arrays, selection and looping statements and various other Java commands. Your program must produce the correct results. The code for the GUI interface is supplied and is available on the unit website, you must write the underlying code to implement the program. The command buttons 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 will need to write comments in the supplied code as well as your own additions.

What to submit for this assignment

The Java source code:
You will need to submit two source files:
Booking.java
and
NemoReefToursGUI.java
, please submit these files as a single zip file. Do not include your report in the zip file you must submit it as a separate file.
o
Ass2.zip
If you submit the source code with an incorrect name you will lose marks.
A report including an
UML diagram of your Booking class
(see text p 493), how long it took to create the whole program, any problems encountered and screen shots of the output produced. (Use Alt-PrtScrn to capture just the application window and you can paste it into your Word document) You should test every possibility in the program.
o
ReportAss2.docx

Assignment Specification

In assignment one we read in multiple booking names and number of passengers using both Scanner and GUI dialogs. In this assignment we are going to read in the data and output the information via a GUI interface. The code for the GUI interface
NemoReefToursGUI.java
is supplied (via the Moodle web site) which supplies the basic functionality of the interface. We are also going to store the information in an array of Booking objects.

java

Look at the code supplied and trace the execution and you will see the buttons are linked to blank methods (stubs) which you will implement the various choices via the buttons.
The GUI interface contains three JLabels for the heading and the prompts. There are two JTextFields in which the booking name and number of passengers are entered. There is also a JTextArea for displaying the output. Four JButtons are at the bottom which link to blank methods for implementing the functionality of the application.

Booking class

First step is to create a class called Booking (Booking.java) which will not contain a main.
The Booking class will be very simple which will contain two
private
instance variables:
o
bookingName
as a String
o
passengers
as an integer
The following public methods will have to be implemented:
o
A default constructor
o
A parameterised constructor
o
Two set methods (mutators)
o
Two get methods (accessors)
o
calculateCharge value returning method*
*You will create a public value returning method calculateCharge(), the tour charges can be derived from the instance variable passengers. Typically we do not store calculated values in a database so the charge will be derived via your calculateCharge() method.
Do not store the charge as an instance variable
.
The method will be similar to calculateCharge method from assignment one, with the same scale of discounts based on the number of passengers.
Charge per person $85.50.
One to two passengers: no discount. From three to five passengers: 10% discount. From six to ten passengers: 15% discount. More than ten passengers: 20% discount.
You should use the following method header:
public double calculateCharge()
Note: you do not need to pass passengers as a parameter as you can access the instance variable passengers directly.

NemoReefToursGUI class
Once the Booking class is implemented and fully tested we can now start to implement the functionality of the GUI interface.

Data structures

For this assignment we are going to store the booking names, number of passengersin an
array
of Booking objects.
Do not use the ArrayList data structure
. Declare an array of Booking objects as an
instance variable of NemoReefToursGUI class
, the array should hold
ten
entries. Use a constant for the maximum entries allowed.
private Booking [] bookingArray = new booking[MAX_BOOKINGS];
We need another instance variable (integer) to keep track of the number of bookings being entered and use this for the index into the array of Booking objects.
private int currentBooking = 0;

Button options

Enter button
:
enter()

For assignment two we are going to use the JTextFields for our input.

Java

When the enter button is pushed the program will transfer to the 
the method:
enter()
this is where we read the booking name and the number of passengers and add them to the Booking array.
The text in the JTextFields is retrieved using the getText() method:
String bookingName = nameField.getText();
When we read the number of passengers input we are reading a string from the GUI, we will need to convert this to an integer using the Integer wrapper class as per assignment one.
int passengers = Integer.parseInt(passengersField.getText());
We need to add these values booking name and number of passengers to the array of Booking objects. When we declared our array using the new keyword, only an array of references were created and we need to create an instance of each of the Booking objects. When we create the Booking object we can pass the booking name and number of passengers to the object via the parameterised constructor.
bookingArray[currentBooking] =  
new Booking(bookingName, passengers);
Remember to increment
currentBooking
at the end of the enter method.
Next we will output the entry including the tour charge in the JTextArea.

Java

The supplied code contains the methods for printing the heading and the line underneath. The font in the text area is “fixed width” so can be aligned using column widths.
displayTextArea.setText(String.format(“%-30s%-17s%-6sn”, “Booking Name”, “Passengers”, “Charge”));
Just like the JTextFields the JTextArea has a method setText() to set the text in the text area, note this overwrites the contents of the text area.
You can append text to the text area by using the append() method.
displayTextArea.append(“———– … ———-n”);
Hint: use the above format string to display all of the values for the booking except the last placeholder for the charge (use: $%5.2f), Java will convert the numerical value of number of passengers to a string for you and the values will align with the headings. To retrieve the values from the array use the get and calculate methods in your Booking class. Create a separate method to display one line of data and pass the index to this method. e.g.
bookingArray[index].getBookingName();
When the data has been entered and displayed, the booking name and number of passengers JTextFields should be cleared. We can clear the contents by using:
nameField.setText(“”);
The focus should then return to the
booking name
JTextField.
nameField.requestFocus();

Data validation
(you can implement this after you have got the basic functionality implemented)
When the maximum number of bookings is reached, do not attempt to add any more bookings and give the following error message:

Java

Use an if statement at the beginning of the method and after displaying the error dialog use the
return
statement to exit the method.
if (nameField.getText().compareTo(“”) == 0) // true when blank
Use the above code to check the name field for text and if there is no text then display the following error dialog and use the
return
statement to exit the method, the focus should return to the name field.

Java

The number of passengers field should also be checked for text and appropriate error dialog displayed. The focus should return to that field.

We will not worry about checking data types or numeric ranges in this assignment.

Display all booking names, number of passengers and charges:
displayAll()

When this option is selected, display all of the booking names, number of passengers and charges which have been entered so far. At the end of the list display the average number of passengers per booking and the total of the charges collected.

java

Use a loop structure to iterate through the array, you should be sharing the printing functionality with
the enter button, hint: use the method to display a line of data from the enter method.
Only print the entries which have been entered so far and not the whole array, use your instance variable
currentBooking
as the termination value in your loop.
Sum the number of passengers in the loop for the average calculation and sum the charges for displaying at the end.
If no entries have been added then clear the text area and display the following error dialog,
repeat this for your search
.

Java

Search for a booking name
:
search()
You can just use a simple linear search which will be
case insensitive
. Use the
JOptionPane.showInputDialog()
method to input the booking name.

If the search is successful display the details about the booking.

java

If the search is unsuccessful display an appropriate message and clear the text area, always return the focus to the nameField.

Java

If the search is unsuccessful display an appropriate message and clear the text area, always return the focus to the nameField.

Java

Exit the application
:
exit()

The exit method is called when the user pushes the exit button or when they select the system close (X at top right hand corner), try and find the code which does this (within the supplied code).
During a typical exiting process we may want to ask the user if they want to save any files they have opened or if they really want to exit, in this assignment we will just print an exit message.

Java

Extra Hints
Your program should be well laid out, commented and uses appropriate and consistent names (camel notation) for all variables, methods and objects.
Ensure you have header comments in both source files, include name, ID, filename, date and purpose of the class.
Make sure you have
no repeated code
(even writing headings and lines in the output), you should try and write a method which accepts an error message as a parameter and displays the error message in a message dialog within the method; use
JOptionPane.ERROR_MESSAGE
as the last parameter in the message dialog.
Constants must be used for all literal numbers in your code (calculateCharge method and maximum entries).

Look at the marking criteria to ensure you have completed all of the necessary items.

Refer to a Java reference textbook and the unit and lecture material (available on the unit web site) for further information about the Java programming topics required to complete this assignment. Check output, check code and add all of your comments, complete report and the UML class diagram.

Supplied Code

Download, compile and run the supplied code available from the unit web site. You will see the GUI interface has been implemented and you have to implement the underlying code, use the supplied method stubs and add you own methods. Look for
// TODO
comments in the code which contain hints. Again no code should be repeated in your program.

This COIT 11222: JAVA Assignment has been solved by our JAVA experts at TVAssignmentHelp. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.

Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.

How to create Testimonial Carousel using Bootstrap5

Clients' Reviews about Our Services