Class 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 Detail

      • when

        private Turn when
        When a sale was made.
      • price

        private int price
        The price per unit returned from the sale.
    • 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 - The Location of the sale.
        what - The GoodsType sold.
        when - In which Turn the 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 which Turn the 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 - The FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem reading the stream.
    • Method Detail

      • getWhen

        public Turn getWhen()
        Get the Turn when the sale was made.
        Returns:
        The Turn when 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 - The Location of the sale.
        what - The GoodsType sold.
        Returns:
        A key string.
      • copyIn

        public <T extends FreeColObject> boolean copyIn​(T other)
        Copy another FreeColObject into this one if it is compatible.
        Overrides:
        copyIn in class FreeColObject
        Type Parameters:
        T - The FreeColObject subclass 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:
        writeAttributes in class FreeColObject
        Parameters:
        xw - The FreeColXMLWriter to 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:
        readAttributes in class FreeColObject
        Parameters:
        xr - The FreeColXMLReader to 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:
        getXMLTagName in class FreeColObject
        Returns:
        The tag.