123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
-
- /**
- * Write a description of class InventoryManager here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
-
- import java.util.ArrayList;
- import java.util.Scanner;
- public class InventoryManager
- {
-
-
- ArrayList<Product> productList = new ArrayList<Product>();
- /**
- * Constructor for objects of class InventoryManager
- */
- public InventoryManager(){
-
- }
-
-
- public void addProduct (String productId, int price, int onHand){
-
- Product productName = new Product(price,productId, onHand);
- productList.add(productName);
- }
-
- public void addInventory (String productId, int quantity){
- if(productList.contains(productId)){
- int index = productList.indexOf(productId);
- productList.get(index).addOnHand(quantity);
- }else System.out.println("Product Not Found!");
- }
-
- public void removeProduct(String productId){
- int index = productList.indexOf(productId);
- productList.remove(index);
- }
-
- public void displayInventory(){
- for(Product p: productList){
- System.out.println(p.getId() + ":");
- System.out.println("On Hand: " + p.getOnHand());
- System.out.println("Price: " + p.getPrice());
- System.out.println("Total Inventory Value: " + p.totalValue());
- }
- }
-
- public String getStringInput(String prompt) {
- Scanner scanner = new Scanner(System.in);
- System.out.println(prompt);
- String userInput = scanner.nextLine();
- String userInput2 = userInput.toLowerCase();
- return userInput2;
- }
-
- public Integer getIntegerInput(String prompt) {
- Scanner scannerB = new Scanner(System.in);
- int b = 0;
- System.out.println(prompt);
- while(b == 0){
- if(scannerB.hasNextInt()){
- b = scannerB.nextInt();
- }else{
- System.out.print("Invalid input please start over\n");
- }
- }
- return b;
- }
-
- }
-
|