|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Market
public class Market
Field Summary | |
---|---|
private Inventory |
inventory
The inventory of this Market |
private double |
marketCostFactor
The cost factor for this market -- how expensive things are here |
Constructor Summary | |
---|---|
Market(double costFactor)
The specific constructor. |
Method Summary | |
---|---|
void |
buyItem(Vehicle vehicle)
Finds the item the vehicle(player) wants to buy in the market's inventory, checks if the player has enough money to buy the item, if so removes it from the market's inventory, adds it to the vehicle's inventory and subtracts the cost from the vechicle's (player's) money. |
void |
createUniqueInventory(int size)
Creates a unique inventory for this market by creating 'size' different and new cargo items and adding them to the inventory. |
void |
enterMarket(Vehicle player)
The main method for doing an action at a market. |
Inventory |
getInventory()
Get the Inventory value. |
double |
getMarketCostFactor()
Get the MarketCostFactor value. |
void |
printInventory()
Prints the contents of the inventory |
void |
printMarketCommands()
Prints the commands available to the player when in the market to the screen |
void |
sellItem(Vehicle vehicle)
Finds the item the vehicle(player) wants to sell in its inventory, removes it from the vehicle's inventory, adds it to the market's inventory and adds the cost to the vechicle's (player's) money. |
void |
setInventory(Inventory newInventory)
Set the Inventory value. |
void |
setMarketCostFactor(double newMarketCostFactor)
Set the MarketCostFactor value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Inventory inventory
private double marketCostFactor
Constructor Detail |
---|
public Market(double costFactor)
costFactor
- The cost factor for the marketMethod Detail |
---|
public Inventory getInventory()
public void setInventory(Inventory newInventory)
newInventory
- The new Inventory value.public double getMarketCostFactor()
public void setMarketCostFactor(double newMarketCostFactor)
newMarketCostFactor
- The new MarketCostFactor value.public void createUniqueInventory(int size)
size
- The size of the inventorypublic void printInventory()
public void printMarketCommands()
public void enterMarket(Vehicle player)
Parser.parse()
), then takes the appropriate action based on
that command. The possible actions include buying cargo,
selling cargo, printing the market's inventory (i.e. cargo
available for trading), printing the vehicle's inventory, and
exiting the market
player
- The vehicle entering the marketpublic void buyItem(Vehicle vehicle)
vehicle
- The vehicle (player) buying the itempublic void sellItem(Vehicle vehicle)
vehicle
- The vehicle (player) selling the item
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |