info-java/Technikladen/StorageManager.java

31 lines
795 B
Java
Raw Normal View History

import java.util.ArrayList;
public class StorageManager {
private ArrayList<Product> storageProducts;
2024-10-18 15:17:59 +02:00
<<<<<<< HEAD
2024-10-15 06:17:06 +02:00
public StorageManager() {
2024-10-15 06:20:09 +02:00
this.storageProducts = new ArrayList<Product>();
2024-10-18 15:17:59 +02:00
=======
public StorageManager(ArrayList<Product> products) {
this.storageProducts = products;
2024-10-18 15:17:59 +02:00
>>>>>>> 89bb3a674e4304644c37109ed5a608b97926deb9
}
public void addProduct(Product product) {
this.storageProducts.add(product);
}
public ArrayList<Product> getStorage() {
return this.storageProducts;
}
public void increaseStorage(int id, int amt) {
this.getProductByID(id).increaseAmount(amt);
}
public Product getProductByID(int id) {
for (Product product : this.storageProducts) {
if (product.getID() == id) {
return product;
}
}
return new Product(-1, "", 0, 0);
}
}