Class WareHolding
- java.lang.Object
-
- ch.sahits.game.openpatrician.model.impl.WareHolding
-
- Direct Known Subclasses:
City,TradingOffice
public abstract class WareHolding extends java.lang.ObjectThis class represents an entity that can hold wares which can be moved- Author:
- Andi Hotz, (c) Sahits GmbH, 2011 Created on Dec 17, 2011
-
-
Field Summary
Fields Modifier and Type Field Description protected ComputablePriceV2computablePrice
-
Constructor Summary
Constructors Constructor Description WareHolding()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddNewWare(IWare ware, int amount)Add a new ware to the wares listprotected voidbindStoredAmount(javafx.beans.property.ReadOnlyIntegerProperty amountProperty)Bind theamountProperty.protected intcomputeAVGPrice(IWare ware, int amount)Compute the average price for ware that is to be purchased in the specified amount.protected booleancontainsWare(IWare ware)Check if there is an amountable object for this wareintgetOccupiedSpace()AmountablePrice<IWare>getWare(IWare ware)Retrieve theAmountablePriceof the ware as it is stored in the holdingintmove(IWare ware, int amount, ICitizen player)Move ware into this holding.javafx.beans.property.IntegerPropertyoccupiedSpaceProperty()voidsetOccupiedSpace(int occupiedSpace)LateIntegerBindingstoredAmountBinding()protected voidunbindAllAmounts()Unbind all bound amounts.
-
-
-
Field Detail
-
computablePrice
@Autowired protected ComputablePriceV2 computablePrice
-
-
Method Detail
-
addNewWare
protected void addNewWare(IWare ware, int amount)
Add a new ware to the wares list- Parameters:
ware- to be addedamount- ofwareto be added.
-
bindStoredAmount
protected void bindStoredAmount(javafx.beans.property.ReadOnlyIntegerProperty amountProperty)
Bind theamountProperty.- Parameters:
amountProperty- to be bound.
-
unbindAllAmounts
protected void unbindAllAmounts()
Unbind all bound amounts.
-
getWare
public AmountablePrice<IWare> getWare(IWare ware)
Retrieve theAmountablePriceof the ware as it is stored in the holding- Parameters:
ware- to be retrieved- Returns:
- AmountablePrice object
-
move
public int move(IWare ware, int amount, ICitizen player)
Move ware into this holding. The player may be null and is not used in this base implementation, but subclasses may be interested for statistical reasons. This method is thread save.- Parameters:
ware- to be movedamount- of the ware that is movedplayer- that initiates the moving, may be null, e.g. if the moving is initiated by a city- Returns:
- the effective amount that was moved. The amount may be positive if something was added, negative if the ware was removed from the holding or zero if nothing was moved.
-
containsWare
protected final boolean containsWare(IWare ware)
Check if there is an amountable object for this ware- Parameters:
ware- to be checked for containemnt- Returns:
- true if the ware is present in the WareHolding.
-
computeAVGPrice
protected int computeAVGPrice(IWare ware, int amount)
Compute the average price for ware that is to be purchased in the specified amount. The additional variable of the available amount is supplied bygetWare(IWare). Subclasses may override this method.- Parameters:
ware- for which the average price is to be computedamount- amount that is bought- Returns:
- average price for the
amountofware.
-
storedAmountBinding
public LateIntegerBinding storedAmountBinding()
-
occupiedSpaceProperty
public javafx.beans.property.IntegerProperty occupiedSpaceProperty()
-
getOccupiedSpace
public int getOccupiedSpace()
-
setOccupiedSpace
public void setOccupiedSpace(int occupiedSpace)
-
-