Language:EN
Pages: 11
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
use the supplied method stubs and add you own meth

Use the supplied method stubs and add you own methods

Assessment details

Assessment item 2—JAVA Program using array of objects

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. Do not write your own GUI interface.

What to submit for this assignment

You will submit your files by the due date using the “Assignment 2” link on the Moodle unit website

under Assessment … Assignment 2 Submission.

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.

Order class
First step is to create a class called Order (Order.java) which will not contain a main method.

The Order class will be very simple which will contain two private instance variables: ocustomerName as a String
omeals as an integer

One or two meals $9.50 per meal plus the delivery charge $2.95.

More than two meals the cost of the extra meals will only be $7.50 per meal.

RockyJohnsGUI class
Once the Order class is implemented and fully tested, we can now start to implement the functionality of the GUI interface.

Data structures

private int currentOrder = 0;

COIT11222, Assignment Two, 2020 Term Three - Page 3 of 11

When the enter button is pushed the program will transfer to the method: enter() this is where we read the customer name and the number of meals and add them to the Order array.

Only add one order when the enter button is pushed, do not have a loop to add them all.

COIT11222, Assignment Two, 2020 Term Three - Page 4 of 11

We need to add customer name and number of meals to the array of Order objects. When we declared our array using the new keyword, only an array of references was created, and we need to create an instance of each of the Order objects. When we create the Order object we can pass the customer name and number of meals to the object via the parameterised constructor.

The supplied code contains the methods for printing the heading and the line underneath. The font in the text area is “fixed width” so the output can be aligned using column widths in the format string.

displayTextArea.setText(String.format("%-30s%-22s%-6s\n", "Customer Name", "Meals", "Charge"));

Hint: use the format string: "%-30s%-22d$%5.2f\n" to display one order to match the specification.

To retrieve the values from the array use the get and calculateCharge methods in your Order class. Create a separate method to display one line of data and pass the index to this method, this is so you will not be repeating the printing code.

nameField.requestFocus();

Data validation (you can implement this after you have the basic functionality implemented)

Checking the name field:
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.

2. Display all orders:displayAll()
When this option is selected, display all of the meal orders which have been entered so far. At the end of the list display the average number of meals per order and the total of the charges collected. .

COIT11222, Assignment Two, 2020 Term Three - Page 7 of 11

COIT11222, Assignment Two, 2020 Term Three - Page 8 of 11

COIT11222, Assignment Two, 2020 Term Three - Page 9 of 11

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.

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

The marking scheme is on the following page.

COIT11222, Assignment Two, 2020 Term Three - Page 10 of 11

Variables, constants and types
0.5
0.5
1
Code in general

Code is indented and aligned correctly and is easy to read (use of vertical whitespace)

1

Each source file has a header comment which includes name, student ID, date, file name and purpose of the class

0.5
1
1
Order class
0.5
0.5

Method for calculating the charge is correct

1

Get and set methods are correct

1
RockyJohnsGUI class
Enter customer name and number of guests
0.5
1
1
1

Order charge is displayed correctly

0.5

Error dialog when maximum orders is reached

0.5
0.5
0.5
0.5
0.5
Display all

All records displayed

1.5
Average and total charges are calculated and displayed correctly 1

Output resembles the specification

0.5
Search
1.5
0.5
0.5
Exit
0.5
General

No orders entered is handled correctly (display all and search)

0.5

Correct files submitted including types and names

1
Report
1
1
0.5

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Barry Powell

PageId: DOC3F30736