Module Server : modif nom packg (utils -> tools) et ajout clss SaleContent dans le packg tools.entities

This commit is contained in:
Notmoo 2017-07-30 17:43:33 +02:00
parent e3c0e510bf
commit dfc2ec93c2
2 changed files with 44 additions and 1 deletions

View File

@ -1,4 +1,4 @@
package com.pqt.server.utils; package com.pqt.server.tools;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;

View File

@ -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<Product, Integer> 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<Product> 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;
}
}