Question: Objective 1 : Reading Items into a Data StructureThe first objective is to read an input file items.txt , which contains data about what items
Objective : Reading Items into a Data StructureThe first objective is to read an input file items.txt which contains data about what items are available for purchase. Figure shows an example of what this file may contain. You can create an instance of such a file for testing purposes. The actual formatting of the files uses a list of commaseparated values so you can easily read them linebyline using Javas Scanner class. Once you have read the file, you should store the items in objects of a suitable custom class and add them to an appropriate data structure.The following requirements must be completed to get full marks for this objective: You should create a function called readItemsfilename that takes as input theitems.txt and adds items to a data structure. It does not need to return anything. Measure the running time for running this function. State the asymptotic worstcase time and space complexity of your function using BigO notation. Objective : Item InventoryThe second objective is to allow the user to manage and query the inventory. The following requirements must be completed to get full marks for this objective: You should create a function called addItemid name, stock, price that takes as input the attributes of a new item then adds a new item to your data structure. It returns true if the addition was successful and false otherwise.You should create a function called updateItemStockid newStock that takes as input the item ID and the new stock then updates the items stock accordingly. It returns true if the update was successful and false otherwise.You should create a function called getStockid that takes as input the item ID and returns the stock available for that item.All of the above functions must run in worstcase time Olg n or less, where n is the number of items.Measure the running time for all functions.Compare your running time of getStock to another function getStockFromArray where items are stored in a simple array instead of the data structure that you initially chose in Objective Objective : Purchasing OperationsThe third objective is to allow the user to initiate and maintain purchases of items. The following requirements must be completed to get full marks for this objective:You should create a method called addNewPurchasearrayOfIds that accepts an array of items IDs and deducts one stock from each item specified in this area. For example if arrayOfIds then it will remove one unit from the stock of item item and item The method will return the total price for this purchase or an error if there is not enough stock for the selected items.You should create a method called undoLastPurchasek that undoes the last k pur chases. The stocks if those items need to be reverted back to their original values.Objective : Most Profitable ItemThe fourth objective should allow the user to find the purchase that yielded the highest value defined as the total price of all items in that purchase For example, Figure shows some purchases that can be made by the user using the items from Figure The highest priced purchase would be Purchase in this case. You should create a function called highestPriced that returns ID of the purchase with the highest total price. The above function must run in worstcase time Olgn or better, where n is the number of customers. Measure the running time of your function.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
