From d0457670278b13eb87e11178a8664cb20bc7074b Mon Sep 17 00:00:00 2001 From: Daniel Poustka Date: Sun, 3 Jan 2021 11:08:23 +0100 Subject: [PATCH] Added containsProduct in Storage. --- .../cvut/fel/sit/omo/foodchain/node/Storage.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/Storage.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/Storage.java index d8b2aed..248f63b 100644 --- a/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/Storage.java +++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/Storage.java @@ -76,6 +76,17 @@ public class Storage return products.contains(product); } + /** + * Checks whether storage contains provided product + * @param name name of product to check + * @param type type of product to check + * @return true if contains, false if not + */ + public boolean containsProduct(String name, ProductType type) + { + return this.getProduct(name,type) != null; + } + /** * Removes provided product from storage if storage contains this product. (Removes only first found) * @param product product to remove @@ -94,8 +105,7 @@ public class Storage public void doAction(ProductOperationType action, Product product) throws IllegalCallerException { if (action.getNode().equals(this.storageOwner.getNodeType())) - new Action(this.storageOwner, this.getProduct(product.getName(), product.getProductType()), action); - //new Action(this.storageOwner, product, action); //todo má se zpracovat produkt co přichází nebo na jeho základě najít tento produkt ve skladu a ten zpracovat??? + new Action(this.storageOwner, product, action); else throw new IllegalCallerException("! IllegalCallerException in NodeBase. " + this.storageOwner.getNodeType().toString() + " cannot do action available only for " + action.getNode()); }