if (train.getCargoBundleNumber() == trainCargoBundle) { trainNumber = trains.getIndex() + 1;
while (trains.next()) { TrainModel train = (TrainModel)trains.getElement();
    public void processMove(Move move) {        //Check whether it is a train arriving at a station.        if (move instanceof TransferCargoAtStationMove) {	    TransferCargoAtStationMove transferCargoAtStationMove =		(TransferCargoAtStationMove)move;	    AddTransactionMove addTransactionMove =		transferCargoAtStationMove.getPayment();	    long revenue = 0;	    DeliverCargoReceipt deliverCargoReceipt = null;	    if (addTransactionMove != null) {		deliverCargoReceipt =		    (DeliverCargoReceipt)addTransactionMove.getTransaction();		revenue = deliverCargoReceipt.getValue();	    }	    // ignore other player's trains	    if (! move.getPrincipal().equals(mr.getPlayerPrincipal()))		return;            if (0 < revenue) {                int trainCargoBundle =		    transferCargoAtStationMove.getChangeOnTrain()                                                                 .getIndex();                int stationCargoBundle =		    transferCargoAtStationMove.getChangeAtStation()                                                                   .getIndex();                NonNullElements trains = new NonNullElements(KEY.TRAINS, world,		       	mr.getPlayerPrincipal());		NonNullElements players = new NonNullElements(KEY.PLAYERS,			world);                int trainNumber = -1;                int statonNumber = -1;                String stationName = Resources.get("No station");                while (trains.next()) {                    TrainModel train = (TrainModel)trains.getElement();                    if (train.getCargoBundleNumber() == trainCargoBundle) {                        trainNumber = trains.getIndex() + 1;                        break;                    }                }		while (players.next()) {		    FreerailsPrincipal p = (FreerailsPrincipal)			((Player) players.getElement()).getPrincipal();		    NonNullElements stations = new NonNullElements(KEY.STATIONS,			    world, p);		    while (stations.next()) {			StationModel station = (StationModel)stations			    .getElement();			if (station.getCargoBundleNumber() ==				stationCargoBundle) {			    statonNumber = stations.getRowNumber();			    stationName = station.getStationName();			    break;			}		    }                }                CargoBundle cb = deliverCargoReceipt.getCargoDelivered();                GameTime gt = (GameTime)world.get(ITEM.TIME);                GameCalendar gc = (GameCalendar)world.get(ITEM.CALENDAR);		GregorianCalendar cal = gc.getCalendar(gt);		DateFormat df =		    DateFormat.getDateTimeInstance(DateFormat.MEDIUM,			    DateFormat.MEDIUM);                String message = df.format(cal.getTime()) + "  Train #" +                    trainNumber + " arrives at " + stationName + "\n";                for (int i = 0; i < world.size(KEY.CARGO_TYPES); i++) {                    int amount = cb.getAmount(i);                    if (amount > 0) {                        CargoType ct = (CargoType)world.get(KEY.CARGO_TYPES, i);                        message += amount + " " + ct.getDisplayName() + "\n";                    }                }                message += "$" + formatter.format(revenue);                mr.getUserMessageLogger().println(message);            }        } else if ((move instanceof AddTransactionMove) &&		move.getPrincipal().equals(mr.getPlayerPrincipal())) {	    Transaction t = (Transaction) ((AddTransactionMove)		    move).getTransaction();	    switch (t.getCategory()) {		case Transaction.CATEGORY_COST_OF_SALES:		    if (t.getSubcategory() == Bill.FUEL) {			mr.getUserMessageLogger().println(Resources.get				("Fuel bill: $") + (-t.getValue()));		    }		    break;		case Transaction.CATEGORY_TAX:		   if (t.getSubcategory() == Bill.INCOME_TAX) {		       mr.getUserMessageLogger().println(Resources.get			       ("Income tax charge: $") + (-t.getValue()));		   }		   break;		case Transaction.CATEGORY_OPERATING_EXPENSE:		   switch (t.getSubcategory()) {		       case Bill.TRACK_MAINTENANCE:			   mr.getUserMessageLogger().println(Resources.get				   ("Track maintenance charge: $") +				   (-t.getValue()));			   break;		       case Bill.ROLLING_STOCK_MAINTENANCE:			   mr.getUserMessageLogger().println(Resources.get				   ("Train maintenance charge: $") + 				   (-t.getValue()));			   break;		   }		   break;		case Transaction.CATEGORY_INTEREST:		  switch (t.getSubcategory()) {		      case InterestTransaction.SUBCATEGORY_OVERDRAFT:			  mr.getUserMessageLogger().println(Resources.get				  ("Overdraft interest charge: $") + 				  (-t.getValue()));			  break;		      case InterestTransaction.SUBCATEGORY_ACCOUNT_CREDIT_INTEREST: 			  mr.getUserMessageLogger().println(Resources.get				  ("Account interest credited: $") +				  (t.getValue()));			  break;		  }	    }	}    }