Programming
Assignment 4
Due March 17, before
9:30am |
||
Program Description |
||
In
this assignment, you will learn about one dimensional arrays. You
will manage a list of groceries. Each item on the list has a
name, quantity, and unit price. |
||
What You Do
|
||
It is assumed that
you are using NetBeans to develop your code for this assignment. Create a new NetBeans project that is a
"General" "Java Application". Name your
NetBeans project program4. Download the source for the Main.java, GroceryItem.java and MyGroceryList.java classes, and store these in the program4/src/program4 directory. Using NetBeans, you are to implement four methods for the class MyGroceryList:
This
method searches the list for item with matching name. The method
is
case-insensitive. Returns a reference to the matching item if one
is
found. Otherwise, returns null
if no matching item is found,
This
method searches the list for the most expensive item, in terms of
maximum unit cost. Returns a reference to the most expensive item. If there are no items on the list, then this
method
returns null.
This
method computes (and returns) the total cost of items on the list, by multiplying
unit cost for each item by quantity. If there is no item
on the list, then the method returns 0.
This
method produces a copy of the grocery list, with the items sorted in
alphabetical order. The sorting is case insensitive. Feel
free to adapt the Selection Sort algorithm given in the textbook.
Programming
Style
You are expected to
follow the CS111
/ CS112 Java Coding Standard. You will be graded on
programming style. Each
student must schedule two meetings with course staff to review a
submitted program's style. Two lab times will be set aside
for this (refer to course schedule). You can also arrange to have
tutors review your program style during scheduled tutoring
hours. This is meant to allow students to get guidance and
feedback on style, and the grading of style is separate from the
grading of Program Assignment 4. |
||
What You Submit
|
||
Submit
your file called MyGroceryList.java
in a directory named 04
via gsubmit
. Under no circumstances will late assignments be accepted. |
||
Grading Criteria
|
||
20%
Submitted code
compiles without errors 20% getItem returns correct value for the cases in Main.java and at testing time. 20% getMostExpensive returns correct value for the cases in Main.java and at testing time. 20% getTotalCost returns correct value for the cases given in Main.java and at testing time. 20% sortAlphabeticalOrder is correct for the cases given in Main.java and at testing time. |
||