2024-10-14 19:08:10 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
public class StorageManager {
|
|
|
|
private ArrayList<Product> storageProducts;
|
2024-10-18 18:19:16 +02:00
|
|
|
public StorageManager() {
|
|
|
|
this.storageProducts = new ArrayList<Product>();
|
2024-10-14 19:08:10 +02:00
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|