Parcourir la source

Product Manager Submit

Nick Satinover il y a 6 ans
Parent
révision
f7a82fcff0

+ 87
- 1
src/main/java/com/zipcodewilmington/productmanager/Inventory.java Voir le fichier

@@ -9,6 +9,10 @@ public class Inventory {
9 9
     LinkedHashMap<Integer, Double> cars = new LinkedHashMap<Integer, Double>();
10 10
     LinkedHashMap<Integer, Double> trucks = new LinkedHashMap<Integer, Double>();
11 11
 
12
+    /**
13
+     * Retrieves all items in current inventory and prints/ returns total inventory value
14
+     * @return inventoryValue
15
+     */
12 16
     public double getInventoryValue(){
13 17
         double inventoryValue = 0;
14 18
         for (Map.Entry<Integer, Double> thisBike : motorcyles.entrySet()) {
@@ -20,7 +24,89 @@ public class Inventory {
20 24
         for (Map.Entry<Integer, Double> thisTruck : trucks.entrySet()) {
21 25
             inventoryValue += thisTruck.getValue();
22 26
         }
23
-        System.out.println("Total inventory value is: " + inventoryValue);
27
+        System.out.println("Total inventory value is: " + inventoryValue + "\n");
24 28
         return  inventoryValue;
25 29
     }
30
+
31
+    /**
32
+     * Adds a new motorcycle to inventory
33
+     * @param newMotorcycle
34
+     */
35
+    public void addMotorcycle(Motorcycle newMotorcycle){
36
+        motorcyles.put(newMotorcycle.getId(), newMotorcycle.getPrice());
37
+    }
38
+
39
+    /**
40
+     * Removes a motorcyle by referencing it's ID
41
+     * @param removeId
42
+     */
43
+    public void removeMotorcyle(Integer removeId){
44
+        if (motorcyles.containsKey(removeId)){
45
+            motorcyles.remove(removeId);
46
+            Motorcycle.decrementQuantity();
47
+        }
48
+        else{
49
+            System.out.println("Invalid ID");
50
+        }
51
+    }
52
+
53
+    public int getMotorcycleQuantity(){
54
+        System.out.println("Motorcyle's in Inventory: " + Motorcycle.getQuantity() + "\n");
55
+        return Motorcycle.getQuantity();
56
+    }
57
+
58
+    /**
59
+     * Adds a new car to inventory
60
+     * @param newCar
61
+     */
62
+    public void addCar(Car newCar){
63
+        cars.put(newCar.getId(), newCar.getPrice());
64
+    }
65
+
66
+    /**
67
+     * Removes a car by referencing it's ID
68
+     * @param removeId
69
+     */
70
+    public void removeCar(Integer removeId){
71
+        if (cars.containsKey(removeId)){
72
+            cars.remove(removeId);
73
+            Car.decrementQuantity();
74
+        }
75
+        else {
76
+            System.out.println("Invalid ID");
77
+        }
78
+
79
+    }
80
+
81
+    public int getCarQuantity(){
82
+        System.out.println("Car's in Inventory: " + Car.getQuantity() + "\n");
83
+        return Car.getQuantity();
84
+    }
85
+
86
+    /**
87
+     * Adds a new truck to inventory
88
+     * @param newTruck
89
+     */
90
+    public void addTruck(Truck newTruck){
91
+        trucks.put(newTruck.getId(), newTruck.getPrice());
92
+    }
93
+
94
+    /**
95
+     * Removes a truck by referencing it's ID
96
+     * @param removeId
97
+     */
98
+    public void removeTruck(Integer removeId){
99
+        if (trucks.containsKey(removeId)) {
100
+            trucks.remove(removeId);
101
+            Truck.decrementQuantity();
102
+        }
103
+        else {
104
+            System.out.println("Invalid ID");
105
+        }
106
+    }
107
+
108
+    public int getTruckQuantity(){
109
+        System.out.println("Truck's in Inventory: " + Truck.getQuantity() + "\n");
110
+        return Truck.getQuantity();
111
+    }
26 112
 }