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
-IAmountable
implementation that is is collected hereby called item
public class AmountablePrice<T extends IAmountable> extends BaseAmountable<T>
This class defines the amounted price of anIWare
object. 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.DoubleProperty
sum
Total 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 void
add(int amount, int avgPrice)
Add a number itemsjavafx.beans.binding.NumberBinding
avgPriceProperty()
boolean
equals(java.lang.Object o)
int
getAVGPrice()
Retrieve the average price of one itemdouble
getSum()
Get the total cum of the amount.int
hashCode()
void
remove(int amount)
Remove a number of itemsvoid
reset()
Set the amount to 0.java.lang.String
toString()
-
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:
remove
in classBaseAmountable<T extends IAmountable>
- Parameters:
amount
- of items to be removed
-
reset
public void reset()
Description copied from class:BaseAmountable
Set the amount to 0.- Overrides:
reset
in classBaseAmountable<T extends IAmountable>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classBaseAmountable<T extends IAmountable>
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classBaseAmountable<T extends IAmountable>
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classBaseAmountable<T extends IAmountable>
-
getSum
public double getSum()
Get the total cum of the amount.- Returns:
- total price of all items.
-
-