mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-12-22 15:31:08 +00:00
Module Server : modif nom packg (utils -> tools) et ajout clss SaleContent dans le packg tools.entities
This commit is contained in:
parent
e3c0e510bf
commit
dfc2ec93c2
@ -1,4 +1,4 @@
|
||||
package com.pqt.server.utils;
|
||||
package com.pqt.server.tools;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user