Answered step by step
Verified Expert Solution
Question
1 Approved Answer
public class ProductNode f ProductNode next; //Constructor # 1 ProductNode () // Intialize other variables here next- null; //Constructor # 2 public class ProductInventory (
public class ProductNode f ProductNode next; //Constructor # 1 ProductNode () // Intialize other variables here next- null; //Constructor # 2 public class ProductInventory ( ProductNode inventoryHead - new ProductNode; public void showInventory) public int getTotalQuantity()i return 0; public ProductNode removeMaximum() return null; public void sortInventory) public void addProduct (String productName, String locator, int quantity, float price)t public void addProduct (String productName, String locator, int quantity, float price)i public void removeProduct (String productName, String locator) public int countProduct (String productName) return 0; public int countNeededQuantity(String productName, int neededQuantity) return class ProductException extends RuntimeException { public ProductException(String s) { super(s) I/ end ProductException // End ProductInventory ----InventoryTester Class Template public class InventoryTester public static void main(String[] args) Product!nventory inventory = new Product!nventory(); // Add Products to inventory inventory.addProduct ( "Apple iphone 7 plus 32gb rose gold", "box256", 10, 699.80); inventory.addProduct( "Apple iphone 7 plus 32gb rose gold", "shelf4", 4, 699.80); inventory.addProduct ( "Apple macbook pro", "box15", 2, 1500.87); inventory.addProduct ("Dell Monitor", "shelf10", 12, 221.54); /7 Show inventory inventory.showInventory); Product Name Locator Quantity Price Apple iphone 7 plus 32gb rose gold box256 Apple iphone 7 plus 32gb rose gold shelf4 Apple macbook pro Dell Monitor 10 4 2 12 699.80 699.80 1500.87 221.54 box14 shelf10 // Sort Products in inventory inventory.sortInventory); // Show inventory After sorting inventory.showInventory); Product Name Locator Quantity Price Dell Monitor Apple iphone 7 plus 32gb rose gold box256 Apple iphone 7 plus 32gb rose gold shelf4 Apple macbook pro shelf10 12 10 4 2 221.54 699.80 699.80 1500.87 box14 System.out.println(inventory.countProduct( "Apple iphone 7 plus 32gb rose gold")); /Should return 14 System.out.println(inventory.countNeededQuantity("Dell Monitor", 15)); // Should return 3 inventory.removeMaximum(); inventory. removeProduct ("Apple iphone 7 plus 32gb rose gold", "shelf4"); System.out.println(inventory.getTotalQuantity)); // Should return 12
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started