Module Core : ajout du coefficient multiplicateur de prix à chaque valeur de l'enum SaleType; ajout méthd getTotalWorth à la clss Sale

This commit is contained in:
Notmoo 2017-07-30 21:27:44 +02:00
parent 5a84ed76a1
commit ee6aa6e70b
2 changed files with 20 additions and 4 deletions

View File

@ -102,10 +102,16 @@ public class Sale implements ILoggable, Serializable{
}
public double getTotalPrice() {
double totalPrice = 0;
for(Product product : this.products.keySet()){
totalPrice+=product.getPrice()*(double)this.products.get(product);
if(type.getPriceMultiplier()==0)
return 0;
return getTotalWorth()*type.getPriceMultiplier();
}
return totalPrice;
public double getTotalWorth(){
double totalWorth = 0;
for(Product product : this.products.keySet()){
totalWorth+=product.getPrice()*(double)this.products.get(product);
}
return totalWorth;
}
}

View File

@ -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;
}
}