de.upb.swtpra05.group03.shuttle
Class Accounting

java.lang.Object
  extended byde.upb.swtpra05.group03.shuttle.Accounting
All Implemented Interfaces:
AccountingInterface, Module, ShuttleModule

public class Accounting
extends java.lang.Object
implements ShuttleModule, AccountingInterface

Bookkeeper which is responsible for any monetary things. It observes the financal situation of one shuttle. All shuttles of the company can't be observed because of the message limit.

Version:
$Revision: 1.3 $

Field Summary
private  int balance
          The current balance of the shuttle
private static java.util.logging.Logger log
          Logger for debugging
private  OrderContainerInterface orderContainer
          The order container
 
Constructor Summary
Accounting()
          Constructor
 
Method Summary
 void drawMoney(int amount)
          Draws an amount of money from the balance value
protected  void drawOrderSelfcosts(de.upb.swtpra.kernel.id.OrderID id)
          Draws the selfcosts of an order from the balance value.
 int getBalance()
          Returns the current balance
 int getEstimatedCosts()
          Returns the estimated costs for all undelivered orders
 void init(ModuleContainerInterface container)
          Initializes this module.
private  void moneyTransferred(de.upb.swtpra.kernel.message.MoneyTransferredMessage msg)
          Pays the order profit in.
 void newMessageReceived(de.upb.swtpra.kernel.message.Message msg)
          React on the received message of the shuttle or not.
private  void paidPenalty(de.upb.swtpra.kernel.message.PaidPenaltyMessage msg)
          Reduces the balance by the penalty.
protected  void payInOrderProfit(de.upb.swtpra.kernel.id.OrderID id)
          Adds the profit of the order to the balance value
private  void shuttleUnLoaded(de.upb.swtpra.kernel.message.ShuttleUnLoadedMessage msg)
          Draws the order selfcosts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final java.util.logging.Logger log
Logger for debugging


balance

private int balance
The current balance of the shuttle


orderContainer

private OrderContainerInterface orderContainer
The order container

Constructor Detail

Accounting

public Accounting()
Constructor

Method Detail

init

public void init(ModuleContainerInterface container)
Description copied from interface: Module
Initializes this module. References to other modules should be set here to avoid circle dependencies.

Specified by:
init in interface Module
Parameters:
container - The module manager which contain all modules

newMessageReceived

public void newMessageReceived(de.upb.swtpra.kernel.message.Message msg)
Description copied from interface: ShuttleModule
React on the received message of the shuttle or not.

Specified by:
newMessageReceived in interface ShuttleModule
Parameters:
msg - The received message of the shuttle

paidPenalty

private void paidPenalty(de.upb.swtpra.kernel.message.PaidPenaltyMessage msg)
Reduces the balance by the penalty.

Parameters:
msg - The PaidPenaltyMessage

moneyTransferred

private void moneyTransferred(de.upb.swtpra.kernel.message.MoneyTransferredMessage msg)
Pays the order profit in.

Parameters:
msg - The MoneyTransferredMessage

shuttleUnLoaded

private void shuttleUnLoaded(de.upb.swtpra.kernel.message.ShuttleUnLoadedMessage msg)
Draws the order selfcosts.

Parameters:
msg - The ShuttleUnLoadedMessage

payInOrderProfit

protected void payInOrderProfit(de.upb.swtpra.kernel.id.OrderID id)
Adds the profit of the order to the balance value

Parameters:
id - The id of the order

drawOrderSelfcosts

protected void drawOrderSelfcosts(de.upb.swtpra.kernel.id.OrderID id)
Draws the selfcosts of an order from the balance value.

Parameters:
id - The id of the order object

getBalance

public int getBalance()
Description copied from interface: AccountingInterface
Returns the current balance

Specified by:
getBalance in interface AccountingInterface
Returns:
The balance value

drawMoney

public void drawMoney(int amount)
Description copied from interface: AccountingInterface
Draws an amount of money from the balance value

Specified by:
drawMoney in interface AccountingInterface
Parameters:
amount - The amount of money to subtract

getEstimatedCosts

public int getEstimatedCosts()
Description copied from interface: AccountingInterface
Returns the estimated costs for all undelivered orders

Specified by:
getEstimatedCosts in interface AccountingInterface
Returns:
The sum of the estimated costs