Class AmountablePrice<T extends IAmountable>
- java.lang.Object
-
- ch.sahits.game.openpatrician.model.BaseAmountable<T>
-
- ch.sahits.game.openpatrician.model.product.AmountablePrice<T>
-
- Type Parameters:
T-IAmountableimplementation that is is collected hereby called item
public class AmountablePrice<T extends IAmountable> extends BaseAmountable<T>
This class defines the amounted price of anIWareobject. Each object in the real world has hits unique price. Since no instances of the objects are used but only one reference the price information gets lost. The amountable price tracks the average price of all amounted objects- Author:
- Andi Hotz, (c) Sahits GmbH, 2011 Created on Nov 20, 2011
-
-
Field Summary
Fields Modifier and Type Field Description private javafx.beans.property.DoublePropertysumTotal price of all amounted items-
Fields inherited from class ch.sahits.game.openpatrician.model.BaseAmountable
fxTheadExecution
-
-
Constructor Summary
Constructors Constructor Description AmountablePrice()AmountablePrice(int amount, double totalPrice)Constructor initalizing the amountablePrice with an amount and average price.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int amount, int avgPrice)Add a number itemsjavafx.beans.binding.NumberBindingavgPriceProperty()booleanequals(java.lang.Object o)intgetAVGPrice()Retrieve the average price of one itemdoublegetSum()Get the total cum of the amount.inthashCode()voidremove(int amount)Remove a number of itemsvoidreset()Set the amount to 0.java.lang.StringtoString()-
Methods inherited from class ch.sahits.game.openpatrician.model.BaseAmountable
add, amountProperty, getAmount, setAmount
-
-
-
-
Constructor Detail
-
AmountablePrice
public AmountablePrice()
-
AmountablePrice
public AmountablePrice(int amount, double totalPrice)Constructor initalizing the amountablePrice with an amount and average price. This constructor is mainly inteded for testing to avoid the hassle with the add method.- Parameters:
amount- represented by this.totalPrice- total price of the complete amount
-
-
Method Detail
-
getAVGPrice
public int getAVGPrice()
Retrieve the average price of one item- Returns:
- average price per item
-
avgPriceProperty
public javafx.beans.binding.NumberBinding avgPriceProperty()
-
add
public void add(int amount, int avgPrice)Add a number items- Parameters:
amount- number of the items to be addedavgPrice- average price of one item that is added
-
remove
public void remove(int amount)
Remove a number of items- Overrides:
removein classBaseAmountable<T extends IAmountable>- Parameters:
amount- of items to be removed
-
reset
public void reset()
Description copied from class:BaseAmountableSet the amount to 0.- Overrides:
resetin classBaseAmountable<T extends IAmountable>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classBaseAmountable<T extends IAmountable>
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classBaseAmountable<T extends IAmountable>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classBaseAmountable<T extends IAmountable>
-
getSum
public double getSum()
Get the total cum of the amount.- Returns:
- total price of all items.
-
-