Question: I need some Help with This Java Please. Write a program that will read a file (unsortedItems.txt)with a number of items. Your program will then

I need some Help with This Java Please.

Write a program that will read a file (unsortedItems.txt)with a number of items. Your program will then store each item that was read form the file to an Array of items. Now that you have all items stored in the Array you need to sort them based on the uid (unique id) and write them to another file (sortedItems.txt).

You will need to design a class named Item that contains:

name: name of the item (String)

uid: unique id of the item (int)

description: description of the itme (String)

price: price of the item (double)

mutator and accessor of name, uid, description and price.

Overloaded Constructor that sets all the instance variables

toString() method returing details on an item in the following format:

uid + | + name + | + description + | price

your Item class need to implement the Comparable interface. When you implement the Comparable interface you will have to implement compareTo method. Your compareTo method should compare two items based on their uid.

You will need another class that you should name ShoppingCart that will do the following:

readItemsFromFile(): read all items from unsortedItems.txt file and store them to an array of Item Type.

sort(): sorts all items stored in the array of items using bubble sort algorithm.

writeSortedItemsToFile(): writes all sorted list back to a new file called sortedItems.txt

displayItems(): print all items in the file to the console

search(int): search for an item based on its uid. If the item is found display it, otherwise display a message saying (item not found).

constructor that accepts an int value to set the size of the items array.

The unsortedItems.txt is a separate file that you need to include inside your projects folder.

Here is the output should look :

I need some Help with This Java Please. Write a program that

About to start reading items from unsrotedItems.txt All items are read successfully form unsortedItems.txt About to start sorting items All items are sorted an stored in itemsList array! About to start writting sorted items to sortedItems.txt Done writting! Start displaying sorted items .. 171 item_3 I description_3 11176.06 271 item_1 I description_1 11295.85 421 item_6 I description 6 11387.96 511 item_2 I description_2 1459.85 511 item_5 I description 5 1880.9 621 item 4 I description_4 1535.32 done displaying! Item with id: 62 is found! 621 item_4 I description 4 1535.32 Item with id: 9999 not found

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!