public static void main(String[] args) {
   DiscountStrategy ds = new DollarDiscount();
   double expectedDiscount = 5.00;
   double actualDiscount = ds.getDiscount(2, 10.00);
   if (expectedDiscount == actualDiscount) {
     System.out.println("Test passes");
   } else {
     System.out.println(
         "Test failed, expected = " + expectedDiscount + " and actual = " + actualDiscount);
   }
 }
 @Override
 public double getDiscount(Order orther) {
   double totalDiscount = 0;
   int qtdDiscouts = 0;
   for (DiscountStrategy d : discounts) {
     double value = d.getDiscount(orther);
     if (value > 0) {
       qtdDiscouts++;
       if (qtdDiscouts > maxAcumulated) break;
       totalDiscount += value;
     }
   }
   return totalDiscount;
 }
Example #3
0
 public double getTotalComDesconto() {
   return total - discountStrategy.getDiscount(this);
 }
 public Double process() {
   return order.getItemTotal() - strategy.discount(order);
 }
Example #5
0
 public final double getDiscount(double total) {
   return discountStrategy.getDiscountInDollars(total);
 }