Package net.sf.freecol.common.model
Class LastSale
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.LastSale
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>,ObjectWithId
public final class LastSale extends FreeColObject
This class contains the last sale a player has made, by Settlement and GoodsType.
-
-
Field Summary
Fields Modifier and Type Field Description private intpriceThe price per unit returned from the sale.private static java.lang.StringPRICE_TAGstatic java.lang.StringTAGprivate TurnwhenWhen a sale was made.private static java.lang.StringWHEN_TAG-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, logger, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
-
Constructor Summary
Constructors Constructor Description LastSale()Trivial constructor to allow creation with Game.newInstance.LastSale(java.lang.String id, Turn when, int price)Make a new LastSale record.LastSale(FreeColXMLReader xr)Create a new last sale by reading a stream.LastSale(Location where, GoodsType what, Turn when, int price)Make a new LastSale record.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends FreeColObject>
booleancopyIn(T other)Copy another FreeColObject into this one if it is compatible.intgetPrice()Get the price from the sale.TurngetWhen()Get theTurnwhen the sale was made.java.lang.StringgetXMLTagName()Get the serialization tag for this object.static java.lang.StringmakeKey(Location where, GoodsType what)Make a String to be used as a key for looking up sales.voidreadAttributes(FreeColXMLReader xr)Reads the attributes of this object from an XML stream.java.lang.StringtoString()protected voidwriteAttributes(FreeColXMLWriter xw)Write the attributes of this object to a stream.-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, equals, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getAbilities, getClassIndex, getDefenceModifiers, getDisplayObject, getFeatureContainer, getFreeColObjectClass, getFreeColObjectClassByName, getGame, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSpecification, getSuffix, getSuffix, hasAbility, hasAbility, hasAbility, hashCode, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readChild, readChildren, readFromXML, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setGame, setId, setSpecification, toXML, toXML, toXMLPartial, toXMLPartial, writeChildren
-
-
-
-
Field Detail
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
when
private Turn when
When a sale was made.
-
price
private int price
The price per unit returned from the sale.
-
PRICE_TAG
private static final java.lang.String PRICE_TAG
- See Also:
- Constant Field Values
-
WHEN_TAG
private static final java.lang.String WHEN_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LastSale
public LastSale()
Trivial constructor to allow creation with Game.newInstance.
-
LastSale
public LastSale(Location where, GoodsType what, Turn when, int price)
Make a new LastSale record.- Parameters:
where- TheLocationof the sale.what- TheGoodsTypesold.when- In whichTurnthe sale occurred.price- The per-unit price of the sale.
-
LastSale
public LastSale(java.lang.String id, Turn when, int price)Make a new LastSale record.- Parameters:
id- The object identifier.when- In whichTurnthe sale occurred.price- The per-unit price of the sale.
-
LastSale
public LastSale(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Create a new last sale by reading a stream.- Parameters:
xr- TheFreeColXMLReaderto read from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
-
Method Detail
-
getWhen
public Turn getWhen()
Get theTurnwhen the sale was made.- Returns:
- The
Turnwhen the sale was made.
-
getPrice
public int getPrice()
Get the price from the sale.- Returns:
- The price from the sale.
-
makeKey
public static java.lang.String makeKey(Location where, GoodsType what)
Make a String to be used as a key for looking up sales.- Parameters:
where- TheLocationof the sale.what- TheGoodsTypesold.- Returns:
- A key string.
-
copyIn
public <T extends FreeColObject> boolean copyIn(T other)
Copy another FreeColObject into this one if it is compatible.- Overrides:
copyInin classFreeColObject- Type Parameters:
T- TheFreeColObjectsubclass of the object to copy in.- Parameters:
other- The other object.- Returns:
- True if the copy in is succesful.
-
writeAttributes
protected void writeAttributes(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
Write the attributes of this object to a stream. To be overridden if required by any object that has attributes and uses the toXML(FreeColXMLWriter, String) call.- Overrides:
writeAttributesin classFreeColObject- Parameters:
xw- TheFreeColXMLWriterto write to.- Throws:
javax.xml.stream.XMLStreamException- if there are any problems writing to the stream.
-
readAttributes
public void readAttributes(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the attributes of this object from an XML stream.- Overrides:
readAttributesin classFreeColObject- Parameters:
xr- TheFreeColXMLReaderto read from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
getXMLTagName
public java.lang.String getXMLTagName()
Get the serialization tag for this object.- Specified by:
getXMLTagNamein classFreeColObject- Returns:
- The tag.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classFreeColObject
-
-