Aktienhandel #4

Merged
Denys Konovalov merged 22 commits from ibartkowski/info-java:main into main 2024-10-18 18:21:55 +02:00
Showing only changes of commit a5fea77649 - Show all commits

@ -1,27 +1,25 @@
package tech_store;
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);
}
}
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);
}
}