org.mars_sim.msp.simulation.person.ai.mission
Class TradeUtil

java.lang.Object
  extended by org.mars_sim.msp.simulation.person.ai.mission.TradeUtil

public final class TradeUtil
extends java.lang.Object

Utility class for static trade methods.


Method Summary
static java.util.Map<Good,java.lang.Integer> determineLoad(Settlement buyingSettlement, Settlement sellingSettlement, Rover rover, double valueLimit)
          Determines the load between a buying settlement and a selling settlement.
static double determineLoadValue(java.util.Map<Good,java.lang.Integer> load, Settlement settlement, boolean buy)
          Determines the value of a load to a settlement.
static double getEstimatedMissionCost(Settlement startingSettlement, Rover rover, double distance)
          Gets the estimated trade mission cost.
static double getNumInInventory(Good good, Inventory inventory)
          Gets the number of a good currently in the inventory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

determineLoad

public static java.util.Map<Good,java.lang.Integer> determineLoad(Settlement buyingSettlement,
                                                                  Settlement sellingSettlement,
                                                                  Rover rover,
                                                                  double valueLimit)
                                                           throws java.lang.Exception
Determines the load between a buying settlement and a selling settlement.

Parameters:
buyingSettlement - the settlement buying the goods.
sellingSettlement - the settlement selling the goods.
rover - the rover to carry the goods.
valueLimit - the value limit for determining the load.
Returns:
map of goods and their number.
Throws:
java.lang.Exception - if error determining the load.

determineLoadValue

public static double determineLoadValue(java.util.Map<Good,java.lang.Integer> load,
                                        Settlement settlement,
                                        boolean buy)
                                 throws java.lang.Exception
Determines the value of a load to a settlement.

Parameters:
load - a map of the goods and their number.
settlement - the settlement valuing the load.
buy - true if settlement is buying the load, false if selling.
Returns:
value of the load (value points).
Throws:
java.lang.Exception - if error determining the load value.

getNumInInventory

public static double getNumInInventory(Good good,
                                       Inventory inventory)
                                throws java.lang.Exception
Gets the number of a good currently in the inventory.

Parameters:
good - the good to check.
inventory - the inventory to check.
Returns:
number of goods in inventory.
Throws:
java.lang.Exception - if error getting number of goods in inventory.

getEstimatedMissionCost

public static double getEstimatedMissionCost(Settlement startingSettlement,
                                             Rover rover,
                                             double distance)
                                      throws java.lang.Exception
Gets the estimated trade mission cost.

Parameters:
startingSettlement - the settlement starting the trade mission.
rover - the mission rover.
distance - the distance (km) of the mission trip.
Returns:
the cost of the mission (value points).
Throws:
java.lang.Exception - if error getting the estimated mission cost.