org.mars_sim.msp.simulation.structure.goods
Class CreditManager

java.lang.Object
  extended by org.mars_sim.msp.simulation.structure.goods.CreditManager
All Implemented Interfaces:
java.io.Serializable

public class CreditManager
extends java.lang.Object
implements java.io.Serializable

The CreditManager class keeps track of all credits/debts between settlements. The simulation instance has only one credit manager.

See Also:
Serialized Form

Constructor Summary
CreditManager()
          Constructor
CreditManager(java.util.Collection settlements)
          Constructor
 
Method Summary
 void addListener(CreditListener newListener)
          Add a listener
 double getCredit(Settlement settlement1, Settlement settlement2)
          Gets the credit between two settlements.
 void removeListener(CreditListener oldListener)
          Remove a listener
 void setCredit(Settlement settlement1, Settlement settlement2, double amount)
          Sets the credit between two settlements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CreditManager

public CreditManager()
Constructor


CreditManager

public CreditManager(java.util.Collection settlements)
Constructor

Parameters:
settlements - collection of settlements to use.
Method Detail

setCredit

public void setCredit(Settlement settlement1,
                      Settlement settlement2,
                      double amount)
               throws java.lang.Exception
Sets the credit between two settlements.

Parameters:
settlement1 - the first settlement.
settlement2 - the second settlement.
amount - the credit amount (VP) that the first settlement has with the second settlement. (negative value if the first settlement owes the second settlement).
Throws:
java.lang.Exception - if error setting the credit between the settlements.

getCredit

public double getCredit(Settlement settlement1,
                        Settlement settlement2)
                 throws java.lang.Exception
Gets the credit between two settlements.

Parameters:
settlement1 - the first settlement.
settlement2 - the second settlement.
Returns:
the credit amount (VP) that the first settlement has with the second settlement. (negative value if the first settlement owes the second settlement).
Throws:
java.lang.Exception - if error getting the credit between the settlements.

addListener

public void addListener(CreditListener newListener)
Add a listener

Parameters:
newListener - The listener to add.

removeListener

public void removeListener(CreditListener oldListener)
Remove a listener

Parameters:
oldListener - the listener to remove.