forked from denyskon/info-java
Igor Bartkowski
89bb3a674e
Technikladen-Aufgaben-Lösung hinzugefügt, weitere kleinere Änderungen werden noch folgen, aber funktional hiermit vollständig Reviewed-on: denyskon/info-java#1 Reviewed-by: Denys Konovalov <kontakt@denyskon.de> Co-authored-by: ibartkowski <ibartkowski@git.cantorgymnasium.de> Co-committed-by: ibartkowski <ibartkowski@git.cantorgymnasium.de>
26 lines
647 B
Java
Executable File
26 lines
647 B
Java
Executable File
import java.util.ArrayList;
|
|
|
|
public class StorageManager {
|
|
private ArrayList<Product> storageProducts;
|
|
public StorageManager(ArrayList<Product> products) {
|
|
this.storageProducts = products;
|
|
}
|
|
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);
|
|
}
|
|
}
|