From dfc2ec93c216f599f4e7cbf4f3c669f173b279cc Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sun, 30 Jul 2017 17:43:33 +0200 Subject: [PATCH] Module Server : modif nom packg (utils -> tools) et ajout clss SaleContent dans le packg tools.entities --- .../pqt/server/{utils => tools}/FileUtil.java | 2 +- .../server/tools/entities/SaleContent.java | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) rename Workspace/server/src/main/WEB-INF/classes/com/pqt/server/{utils => tools}/FileUtil.java (96%) create mode 100644 Workspace/server/src/main/WEB-INF/classes/com/pqt/server/tools/entities/SaleContent.java diff --git a/Workspace/server/src/main/WEB-INF/classes/com/pqt/server/utils/FileUtil.java b/Workspace/server/src/main/WEB-INF/classes/com/pqt/server/tools/FileUtil.java similarity index 96% rename from Workspace/server/src/main/WEB-INF/classes/com/pqt/server/utils/FileUtil.java rename to Workspace/server/src/main/WEB-INF/classes/com/pqt/server/tools/FileUtil.java index 5964ab4f..1a0fc195 100644 --- a/Workspace/server/src/main/WEB-INF/classes/com/pqt/server/utils/FileUtil.java +++ b/Workspace/server/src/main/WEB-INF/classes/com/pqt/server/tools/FileUtil.java @@ -1,4 +1,4 @@ -package com.pqt.server.utils; +package com.pqt.server.tools; import java.io.IOException; import java.nio.file.Files; diff --git a/Workspace/server/src/main/WEB-INF/classes/com/pqt/server/tools/entities/SaleContent.java b/Workspace/server/src/main/WEB-INF/classes/com/pqt/server/tools/entities/SaleContent.java new file mode 100644 index 00000000..aeb2e7d8 --- /dev/null +++ b/Workspace/server/src/main/WEB-INF/classes/com/pqt/server/tools/entities/SaleContent.java @@ -0,0 +1,43 @@ +package com.pqt.server.tools.entities; + +import com.pqt.core.entities.product.Product; +import com.pqt.core.entities.sale.Sale; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +public class SaleContent { + private Map content; + + public SaleContent() { + content = new HashMap<>(); + } + + public SaleContent(Sale sale){ + content = new HashMap<>(sale.getProducts()); + } + + public void addProduct(Product product, Integer amount){ + if(content.containsKey(product)){ + content.replace(product, content.get(product)+amount); + }else{ + content.put(product, amount); + } + } + + public Collection getProductList(){ + return content.keySet(); + } + + public boolean contains(Product product){ + return content.containsKey(product); + } + + public Integer getProductAmount(Product product){ + if(content.containsKey(product)) + return content.get(product); + + return null; + } +}