Starting from:

$30

CST8130-Assignment 2 Sorting/Searching using ArrayList, using Files Solved

In this assignment, you will modify a solution to Assignment 1 with two modifications.   You may use your solution, or my posted solution for Assignment 1.  

 

1.        Efficiency:  You will make the Inventory data structure more efficient in two ways:

 

a)      Change the inventory declaration in Inventory class to be an object of ArrayList. 

 

b)      Change the insert into the inventory data structure so that the Item objects are in numeric order  from smallest to largest by itemCode in the most efficient way possible.   Once the inventory structure is ordered, modify your other methods to also make them as efficient as possible.  (Note – do NOT use Generic Collection methods yet – we need to learn to do the coding ourselves first).

 

2.        Saving data:  You will add two menu selections to your assignment:

 

a)      the first  will save the contents of the inventory ArrayList to a file

 

b)      and the second will ready the contents of a file to the inventory ArrayList. 

 

I have given you a copy of a good file to get you started - it has one line per Item.  You can see the format of each line in the file. 

 

Remember, you must write EFFICIENT code.  You do not know how many lines will be in the file when you open it.  You also don’t know the name of the file so you cannot hard-code it in your program.   Finally, I have not included bad files, but as always, your code must handle all possibilities.

More products