123456789101112131415161718192021222324252627282930313233343536 |
-
- /**
- * Write a description of class Inventory here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- import java.util.ArrayList;
- public class Inventory {
- ArrayList<Product> products = new ArrayList<Product>();
- private static double totalValue;
- private static int totalQuantity;
-
- public double getTotalValue() {
- return totalValue;
- }
-
- public int getTotalQuantity() {
- return totalQuantity;
- }
-
- public void addToInventory(Product fresh) {
- products.add(fresh);
- totalValue += (fresh.getPrice() * fresh.getQuantity());
- totalQuantity += fresh.getQuantity();
- }
-
- public void removeFromInventory(Product old) {
- products.remove(old);
- totalValue -= (old.getPrice() * old.getQuantity());
- totalQuantity -= old.getQuantity();
- }
-
-
- }
|