Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C https//grid.cs.gsu.edu/-sfilaliboubrahimi1/Assignment3.pdf 1/4 Turn the java files in Folder Assignment 3 in iCollege no later than 11:59 p.m. on 03/17/2018 Note Handle all the possible

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

C https//grid.cs.gsu.edu/-sfilaliboubrahimi1/Assignment3.pdf 1/4 Turn the java files in Folder Assignment 3 in iCollege no later than 11:59 p.m. on 03/17/2018 Note Handle all the possible exceptions regarding insertion, deletion or update operations in the list using the given ProductException class. Requirements: You have a new project in your company and your client is a small shopkeeper that needs to manage the shop inventory. Your job is to design and implement ProductNode and Productinventory classes that manage the inventory using a linked List ADT. The specifications of the two classes are as follows: ProductNode Class For each product, you should store the following info 1. Product Name (i.e. "Apple iphone 7 plus 32gb rose gold", may contain spaces in it, not unique) 2. Locator (string used to physically locate product, not unique) 3. Quantity (how many of this product in stock, greater than or equal to O) 4. Price (in dollars and cents, greater than 0) Note: For a given product, the product name AND locator together must be unique. So you may have two entries for "iPhone 5c" if one has "box3" for the locator and the other has "shelf12" You should implement two constructors A constructor that takes no arguments (quantity and price are initialized to 0, product name and locator are initialized to empty strings) A constructor that takes a value for each of the four-member variables. 4:58 PM 3/8/2019 https://grid.cs.gsu.edu/~sfilaliboubrahimi1/Assignment3.pdf 2/4 showlnventory: displays a listing of the product inventory to the screen, one product entry per line. Output locator, then quantity, then price, then product name. getTotalQuantity: returns the total number of units of all of the products in the inventory removeMaximum: finds the maximum product in the list based in the quantity. It removes the node of the maximum from the list and returns a pointer to this node. sortinventory: reorders the products in the list based on their quantity, using removeMaximum. Here is the algorithm you must use for implementing the sort function. It is a form of the selection sort. It selects the next (maximum) element from the current list and removes its node from the current list, and then inserts the node at the front of a new list (pointed to by a temporary pointer). When finished, it makes the old head pointer point to the new list. "inventoryHead" is the head pointer and while inventoryHead is not empty find the maximum product in inventoryHead list and remove it (i.e. call removeMaximum) add the maximum node to the front of a new temporary list end and finally make inventoryHead point to the new temporary list. addProduct: takes a product and adds it to the inventory. If a product with the same name and locator already exists in the inventory or if the quantity or price are invalid, the function throws a ProductException. removeProduct: takes a product name and locator and removes any matching product form the inventory countProduct: since the same product can exist in the inventory with different locators. The function should take the name of a given product, traverse the inventory list and count the quantity of the same product. countNeededQuantity: the store keeper needs to order products in the inventory to avoid any future shortage. The function should take the name of the product and the desired quantity of a given product as an argument. The function calls countProduct to deduce the needed quantity. 4:59 PM 3/8/2019 https://grid.cs.gsu.edu/~sfilaliboubrahimi1/Assignment3.pdf 3/4 Intialize other variables here next- null //Constructor # 2 ProductNode Class Template public class ProductInventory c ProductNode InventoryHead-new ProductNode) public void showInventory) public int getTotalQuantityO return 8 public ProductNode renoveMainnO return null; public void sortInventoryO public void addProduct(String productNane, String locator, int quantity, float price) public void renoveProduct (String productName, String locator) public int countProduct (String productName) return 8 public int countNeededQuantity(String productNane, int neededQuantity) return 0 class ProductException extends RuntineException public ProductException(String s) super(s) / end ProductException 5:01 PM 3/8/2019 https://grid.cs.gsu.edu/~sfilaliboubrahimi1/Assignment3.pdf public class InventoryTester ( public static void main(String[] args) Add Products to inventory inventory.addProduct Apple iphone 7 plus 32eb rose eold" "box256, 18, 699.88) inventory, addProduct("Apple phone 7 plus 32gb rose gold", "shelf4", 4, 699, 80); Inventory.addProduct("Apple nacbook pro", "box152, 158e.87); Inventory.addProduct( Dell Moniton, "she1f18, 12, 221.54); Show inventory inventory.showInventory) Product Name LocatorQuantity Price Apple iphon 7 plus 32gb rose gold Apple iPhone 7 plus 32gb rose gold Apple nacbook pro Dell Monitor box256 shelf boxl4 shelfie 699.88 699.88 221.54 Sort Products in inventory inventory.sortInventory) II Show inventory After sorting inventory.showInventory) Product Name Locator tity Price Dell Monitor Apple iphon 7 plus 32gb rose gold box256 Apple iphone 7 plus 32gb rose gold shelf4 Apple nacbook pro shelfie 221.54 699, 88 box14 Systen.out.printin(inventory.countProduct('Apple phone 7 plus 32gb rose eold.)); 1 Should return 14 Systen.out.printin(inventory.countNeededQuantity("Dell Moniton, 15)); / Should return 3 inventory.retoveMaxinun(O; inventory.retoveProduct( Apple iphone 7 plus 32gb rose gold,"shelf4); Systen.out.printin(inventory getTotalQuantity) I Should return 12 H 5:02 PM 3/8/2019 C https//grid.cs.gsu.edu/-sfilaliboubrahimi1/Assignment3.pdf 1/4 Turn the java files in Folder Assignment 3 in iCollege no later than 11:59 p.m. on 03/17/2018 Note Handle all the possible exceptions regarding insertion, deletion or update operations in the list using the given ProductException class. Requirements: You have a new project in your company and your client is a small shopkeeper that needs to manage the shop inventory. Your job is to design and implement ProductNode and Productinventory classes that manage the inventory using a linked List ADT. The specifications of the two classes are as follows: ProductNode Class For each product, you should store the following info 1. Product Name (i.e. "Apple iphone 7 plus 32gb rose gold", may contain spaces in it, not unique) 2. Locator (string used to physically locate product, not unique) 3. Quantity (how many of this product in stock, greater than or equal to O) 4. Price (in dollars and cents, greater than 0) Note: For a given product, the product name AND locator together must be unique. So you may have two entries for "iPhone 5c" if one has "box3" for the locator and the other has "shelf12" You should implement two constructors A constructor that takes no arguments (quantity and price are initialized to 0, product name and locator are initialized to empty strings) A constructor that takes a value for each of the four-member variables. 4:58 PM 3/8/2019 https://grid.cs.gsu.edu/~sfilaliboubrahimi1/Assignment3.pdf 2/4 showlnventory: displays a listing of the product inventory to the screen, one product entry per line. Output locator, then quantity, then price, then product name. getTotalQuantity: returns the total number of units of all of the products in the inventory removeMaximum: finds the maximum product in the list based in the quantity. It removes the node of the maximum from the list and returns a pointer to this node. sortinventory: reorders the products in the list based on their quantity, using removeMaximum. Here is the algorithm you must use for implementing the sort function. It is a form of the selection sort. It selects the next (maximum) element from the current list and removes its node from the current list, and then inserts the node at the front of a new list (pointed to by a temporary pointer). When finished, it makes the old head pointer point to the new list. "inventoryHead" is the head pointer and while inventoryHead is not empty find the maximum product in inventoryHead list and remove it (i.e. call removeMaximum) add the maximum node to the front of a new temporary list end and finally make inventoryHead point to the new temporary list. addProduct: takes a product and adds it to the inventory. If a product with the same name and locator already exists in the inventory or if the quantity or price are invalid, the function throws a ProductException. removeProduct: takes a product name and locator and removes any matching product form the inventory countProduct: since the same product can exist in the inventory with different locators. The function should take the name of a given product, traverse the inventory list and count the quantity of the same product. countNeededQuantity: the store keeper needs to order products in the inventory to avoid any future shortage. The function should take the name of the product and the desired quantity of a given product as an argument. The function calls countProduct to deduce the needed quantity. 4:59 PM 3/8/2019 https://grid.cs.gsu.edu/~sfilaliboubrahimi1/Assignment3.pdf 3/4 Intialize other variables here next- null //Constructor # 2 ProductNode Class Template public class ProductInventory c ProductNode InventoryHead-new ProductNode) public void showInventory) public int getTotalQuantityO return 8 public ProductNode renoveMainnO return null; public void sortInventoryO public void addProduct(String productNane, String locator, int quantity, float price) public void renoveProduct (String productName, String locator) public int countProduct (String productName) return 8 public int countNeededQuantity(String productNane, int neededQuantity) return 0 class ProductException extends RuntineException public ProductException(String s) super(s) / end ProductException 5:01 PM 3/8/2019 https://grid.cs.gsu.edu/~sfilaliboubrahimi1/Assignment3.pdf public class InventoryTester ( public static void main(String[] args) Add Products to inventory inventory.addProduct Apple iphone 7 plus 32eb rose eold" "box256, 18, 699.88) inventory, addProduct("Apple phone 7 plus 32gb rose gold", "shelf4", 4, 699, 80); Inventory.addProduct("Apple nacbook pro", "box152, 158e.87); Inventory.addProduct( Dell Moniton, "she1f18, 12, 221.54); Show inventory inventory.showInventory) Product Name LocatorQuantity Price Apple iphon 7 plus 32gb rose gold Apple iPhone 7 plus 32gb rose gold Apple nacbook pro Dell Monitor box256 shelf boxl4 shelfie 699.88 699.88 221.54 Sort Products in inventory inventory.sortInventory) II Show inventory After sorting inventory.showInventory) Product Name Locator tity Price Dell Monitor Apple iphon 7 plus 32gb rose gold box256 Apple iphone 7 plus 32gb rose gold shelf4 Apple nacbook pro shelfie 221.54 699, 88 box14 Systen.out.printin(inventory.countProduct('Apple phone 7 plus 32gb rose eold.)); 1 Should return 14 Systen.out.printin(inventory.countNeededQuantity("Dell Moniton, 15)); / Should return 3 inventory.retoveMaxinun(O; inventory.retoveProduct( Apple iphone 7 plus 32gb rose gold,"shelf4); Systen.out.printin(inventory getTotalQuantity) I Should return 12 H 5:02 PM 3/8/2019

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

More Books

Students also viewed these Databases questions

Question

Brief the importance of span of control and its concepts.

Answered: 1 week ago

Question

What is meant by decentralisation?

Answered: 1 week ago