From: Erik V. <ev...@us...> - 2009-09-25 19:13:17
|
Update of /cvsroot/rails/18xx/rails/game/move In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv5549/rails/game/move Modified Files: CashMove.java Log Message: Rationalised Bank, removing statics Removed two unnecessary Util methods Index: CashMove.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/move/CashMove.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CashMove.java 4 Jun 2008 19:00:33 -0000 1.4 --- CashMove.java 25 Sep 2009 19:13:01 -0000 1.5 *************** *** 1,4 **** /* $Header$ ! * * Created on 17-Jul-2006 * Change Log: --- 1,4 ---- /* $Header$ ! * * Created on 17-Jul-2006 * Change Log: *************** *** 6,10 **** package rails.game.move; ! import rails.game.*; /** --- 6,11 ---- package rails.game.move; ! import rails.game.Bank; ! import rails.game.CashHolder; /** *************** *** 22,26 **** * Create a CashMove instance. In this specific case either from or to may * be null, in which case the Bank is implied. ! * * @param from The cash payer (null implies the Bank). * @param to The cash payee (null implies the Bank). --- 23,27 ---- * Create a CashMove instance. In this specific case either from or to may * be null, in which case the Bank is implied. ! * * @param from The cash payer (null implies the Bank). * @param to The cash payee (null implies the Bank). *************** *** 35,51 **** } ! public boolean execute() { ! Bank.transferCash(from, to, amount); return true; } ! public boolean undo() { ! Bank.transferCash(to, from, amount); return true; } ! public String toString() { return "CashMove: " + Bank.format(amount) + " from " + from.getName() + " to " + to.getName(); --- 36,60 ---- } ! @Override ! public boolean execute() { ! transferCash(from, to, amount); return true; } ! @Override ! public boolean undo() { ! transferCash(to, from, amount); return true; } ! private boolean transferCash(CashHolder from, CashHolder to, ! int amount) { ! return to.addCash(amount) && from.addCash(-amount); ! } ! ! @Override ! public String toString() { return "CashMove: " + Bank.format(amount) + " from " + from.getName() + " to " + to.getName(); |