|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.freecol.common.model.FreeColObject
net.sf.freecol.common.model.FreeColGameObject
net.sf.freecol.common.model.Market
public final class Market
This class implements a simple economic model whereby a market holds all goods that have been sold and the price of a particular type of good is determined solely by its availability in that market.
Field Summary | |
---|---|
static int |
CUSTOM_HOUSE
Constant for specifying the access to this Market
when buying and
selling goods. |
static int |
EUROPE
Constant for specifying the access to this Market
when buying and
selling goods. |
static int |
MAXIMUM_PRICE
|
static int |
MINIMUM_PRICE
|
Fields inherited from class net.sf.freecol.common.model.FreeColObject |
---|
ID_ATTRIBUTE_TAG |
Constructor Summary | |
---|---|
Market(Game game,
org.w3c.dom.Element e)
Initiates a new Market from an
XML representation. |
|
Market(Game game,
Player player)
|
|
Market(Game game,
java.lang.String id)
Initiates a new Market with the given ID. |
|
Market(Game game,
javax.xml.stream.XMLStreamReader in)
Initiates a new Market from an
XML representation. |
Method Summary | |
---|---|
boolean |
addGoodsToMarket(GoodsType goodsType,
int amount)
Add (or remove) some goods to this market. |
void |
addTransactionListener(TransactionListener listener)
Adds a transaction listener for notification of any transaction |
void |
buy(GoodsType goodsType,
int amount,
Player player)
Buys an amount of a particular type of good with the cost being met by a supplied player. |
int |
costToBuy(GoodsType type)
Determines the cost to buy a single unit of a particular type of good. |
int |
getBidPrice(GoodsType type,
int amount)
Gets the price of a given goods when the Player buys. |
MarketData |
getMarketData(GoodsType goodsType)
Return the market data for a type of goods. |
Player |
getOwner()
Gets the owner of this Market . |
int |
getSalePrice(Goods goods)
Gets the price of a given goods when the Player sells. |
int |
getSalePrice(GoodsType type,
int amount)
Gets the price of a given goods when the Player sells. |
TransactionListener[] |
getTransactionListener()
Returns an array of all the TransactionListener added to this Market. |
static java.lang.String |
getXMLElementTagName()
Returns the tag name of the root element representing this object. |
ModelMessage |
makePriceMessage(GoodsType goodsType)
Make up a ModelMessage describing the change in this
Market for a specified type of goods. |
int |
paidForSale(GoodsType type)
Determines the price paid for the sale of a single unit of a particular type of goods. |
void |
putMarketData(GoodsType goodsType,
MarketData data)
Describe putMarketData method here. |
void |
removeTransactionListener(TransactionListener listener)
Removes a transaction listener |
void |
sell(Goods goods,
Player player)
Sells an amount of a particular type of good with the proceeds of the sale being paid to a supplied player. |
void |
sell(GoodsType type,
int amount,
Player player)
Sells an amount of a particular type of good with the proceeds of the sale being paid to a supplied player. |
void |
sell(GoodsType type,
int amount,
Player player,
int marketAccess)
Sells an amount of a particular type of good with the proceeds of the sale being paid to a supplied player. |
void |
setOwner(Player owner)
Sets the owner of this Market . |
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject |
---|
addToRemoveElement, dispose, equals, equals, getFreeColGameObject, getFreeColGameObject, getGame, getGameOptions, getIntegerID, hashCode, hasID, isDisposed, isUninitialized, readFromXML, setGame, setId, toSavedXML, toString, toXML, updateFreeColGameObject, updateID |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int MINIMUM_PRICE
public static final int MAXIMUM_PRICE
public static final int EUROPE
Market
when buying
and
selling
goods.
public static final int CUSTOM_HOUSE
Market
when buying
and
selling
goods.
Constructor Detail |
---|
public Market(Game game, Player player)
public Market(Game game, javax.xml.stream.XMLStreamReader in) throws javax.xml.stream.XMLStreamException
Market
from an
XML representation.
game
- The Game
this object belongs to.in
- The input stream containing the XML.
javax.xml.stream.XMLStreamException
- if a problem was encountered
during parsing.public Market(Game game, org.w3c.dom.Element e)
Market
from an
XML representation.
game
- The Game
this object belongs to.e
- An XML-element that will be used to initialize
this object.public Market(Game game, java.lang.String id)
Market
with the given ID.
The object should later be initialized by calling either
FreeColGameObject.readFromXML(XMLStreamReader)
or
FreeColObject.readFromXMLElement(Element)
.
game
- The Game
in which this object belong.id
- The unique identifier for this object.Method Detail |
---|
public MarketData getMarketData(GoodsType goodsType)
goodsType
- a GoodsType
value
MarketData
valuepublic void putMarketData(GoodsType goodsType, MarketData data)
putMarketData
method here.
goodsType
- a GoodsType
valuedata
- a MarketData
valuepublic Player getOwner()
Market
.
getOwner
in interface Ownable
Market
.public void setOwner(Player owner)
Market
.
setOwner
in interface Ownable
owner
- The Player
that shall own this Market
.public int costToBuy(GoodsType type)
type
- A GoodsType
value.
public int paidForSale(GoodsType type)
type
- A GoodsType
value.
public void sell(Goods goods, Player player)
EUROPE
as the accesspoint for this market.
Note that post-independence this no longer refers to a specific port.
goods
- The Goods
object being sold.player
- The Player
selling the goods.public void sell(GoodsType type, int amount, Player player)
EUROPE
as the accesspoint for this market.
type
- The type of goods to be sold.amount
- The amount of goods to be sold.player
- The Player
selling the goods.public void sell(GoodsType type, int amount, Player player, int marketAccess)
type
- The type of goods to be sold.amount
- The amount of goods to be sold.player
- The Player
selling the goods.marketAccess
- The place where goods are traded.public void buy(GoodsType goodsType, int amount, Player player)
goodsType
- The type of the good that is being bought.amount
- The amount of goods that are being bought.player
- The Player
buying the goods.
java.lang.IllegalStateException
- If the player
cannot afford
to buy the goods.public boolean addGoodsToMarket(GoodsType goodsType, int amount)
goodsType
- The GoodsType
to add.amount
- The amount of goods.
public int getBidPrice(GoodsType type, int amount)
Player
buys.
type
- a GoodsType
valueamount
- The amount of goods.
public int getSalePrice(GoodsType type, int amount)
Player
sells.
type
- a GoodsType
valueamount
- The amount of goods.
public int getSalePrice(Goods goods)
Player
sells.
goods
- a Goods
value
int
valuepublic void addTransactionListener(TransactionListener listener)
listener
- the listenerpublic void removeTransactionListener(TransactionListener listener)
listener
- the listenerpublic TransactionListener[] getTransactionListener()
public ModelMessage makePriceMessage(GoodsType goodsType)
ModelMessage
describing the change in this
Market
for a specified type of goods.
goodsType
- The GoodsType
that has changed price.
public static java.lang.String getXMLElementTagName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |