| java.lang.Object org.mandarax.examples.db.Discount
Discount | public class Discount implements java.io.Serializable(Code) | | Discount. A discount can be given in percent (relative
discount) or in $ (absolute discount). This class is a very simple business object type
and shows how (arbitrary) objects are integrated. Being serializable is not required but recommended to support
technologies such as Serialization, RMI and EJB.
since: 2.2 author: Jens Dietrich version: 3.4 <7 March 05> |
Constructor Summary | |
public | Discount() Constructor. | public | Discount(double d) Constructor. | public | Discount(double d, boolean rel) Constructor. |
Method Summary | |
public double | apply(double amount) Apply the discount to an amount. | public double | getRate() Get the rate. | public boolean | isRelative() Indicates whether the discount is relative. | public void | setRate(double r) Set the rate. | public void | setRelative(boolean flag) Set the relative property. | public String | toString() Convert the object to a string. |
Discount | public Discount()(Code) | | Constructor.
|
Discount | public Discount(double d)(Code) | | Constructor. The discount will be relative (a percentage)
Parameters: d - the discount |
Discount | public Discount(double d, boolean rel)(Code) | | Constructor. The discount will be relative (a percentage)
Parameters: d - the discount Parameters: rel - - if true, the discount will be relative (a percentage),if false, the discount will be absolute (an amount of US $) |
apply | public double apply(double amount)(Code) | | Apply the discount to an amount.
the final amount (-discount) Parameters: amount - an amount |
getRate | public double getRate()(Code) | | Get the rate.
the discount rate (either an absolute amount or a percentage value) |
isRelative | public boolean isRelative()(Code) | | Indicates whether the discount is relative.
true if the discount is a percentage, false otherwise (= if it is an absolute amount) |
setRate | public void setRate(double r)(Code) | | Set the rate.
Parameters: r - a value |
setRelative | public void setRelative(boolean flag)(Code) | | Set the relative property.
Parameters: flag - true if this should be a percentage value, false otherwise |
toString | public String toString()(Code) | | Convert the object to a string.
|
|
|