KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > store > adjustments > SaleAdjustment


1 /*
2  * Created on Sep 23, 2004
3  */

4 package com.openedit.store.adjustments;
5
6 import org.openedit.money.Fraction;
7 import org.openedit.money.Money;
8
9 import com.openedit.store.Cart;
10 import com.openedit.store.CartItem;
11
12 /**
13  * @author Matthew Avery, mavery@einnovation.com
14  */

15 public class SaleAdjustment implements Adjustment
16 {
17     protected Fraction fieldPercentage;
18     
19     public SaleAdjustment()
20     {
21         super();
22         // TODO Auto-generated constructor stub
23
}
24
25     public Money adjust( Cart inCart, CartItem inItem )
26     {
27         return inItem.getYourPrice().multiply( Fraction.ONE.subtract( getPercentage() ) );
28     }
29
30     public void setPercentDiscount( double inAdjustmentPercentage )
31     {
32         fieldPercentage = new Fraction( inAdjustmentPercentage / 100 );
33     }
34
35     protected Fraction getPercentage()
36     {
37         return fieldPercentage;
38     }
39
40 }
41
Popular Tags