From ee6aa6e70b3b4a199e7968debd50e2cb6eeddbd7 Mon Sep 17 00:00:00 2001 From: Notmoo Date: Sun, 30 Jul 2017 21:27:44 +0200 Subject: [PATCH] =?UTF-8?q?Module=20Core=20:=20ajout=20du=20coefficient=20?= =?UTF-8?q?multiplicateur=20de=20prix=20=C3=A0=20chaque=20valeur=20de=20l'?= =?UTF-8?q?enum=20SaleType;=20ajout=20m=C3=A9thd=20getTotalWorth=20=C3=A0?= =?UTF-8?q?=20la=20clss=20Sale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/pqt/core/entities/sale/Sale.java | 12 +++++++++--- .../java/com/pqt/core/entities/sale/SaleType.java | 12 +++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Workspace/core/src/main/java/com/pqt/core/entities/sale/Sale.java b/Workspace/core/src/main/java/com/pqt/core/entities/sale/Sale.java index 47adb233..dcaded4a 100644 --- a/Workspace/core/src/main/java/com/pqt/core/entities/sale/Sale.java +++ b/Workspace/core/src/main/java/com/pqt/core/entities/sale/Sale.java @@ -102,10 +102,16 @@ public class Sale implements ILoggable, Serializable{ } public double getTotalPrice() { - double totalPrice = 0; + if(type.getPriceMultiplier()==0) + return 0; + return getTotalWorth()*type.getPriceMultiplier(); + } + + public double getTotalWorth(){ + double totalWorth = 0; for(Product product : this.products.keySet()){ - totalPrice+=product.getPrice()*(double)this.products.get(product); + totalWorth+=product.getPrice()*(double)this.products.get(product); } - return totalPrice; + return totalWorth; } } diff --git a/Workspace/core/src/main/java/com/pqt/core/entities/sale/SaleType.java b/Workspace/core/src/main/java/com/pqt/core/entities/sale/SaleType.java index 7dbf33c8..415738dc 100644 --- a/Workspace/core/src/main/java/com/pqt/core/entities/sale/SaleType.java +++ b/Workspace/core/src/main/java/com/pqt/core/entities/sale/SaleType.java @@ -4,5 +4,15 @@ package com.pqt.core.entities.sale; * Created by Notmoo on 18/07/2017. */ public enum SaleType { - CASH, BANK_CHECK, STUDENT_ASSOCIATION_ACCOUNT, OFFERED_GUEST, OFFERED_STAFF_MEMBER + CASH(1), BANK_CHECK(1), STUDENT_ASSOCIATION_ACCOUNT(1), OFFERED_GUEST(0), OFFERED_STAFF_MEMBER(0); + + private double priceMultiplier; + + SaleType(double priceMultiplier) { + this.priceMultiplier = priceMultiplier; + } + + public double getPriceMultiplier() { + return priceMultiplier; + } }