package fauxExchange; class TradingState extends State { private static RuleManager rm, initRM; static { //Have a seperate initRule to process the orderBook right before open trading Rule init = new AuctionRule(); initRM = new RuleManager(); initRM.addRule(init); // //Add all the tradingRules for this state... Rule mmr = new MarketMarketRule(); Rule mlr = new MarketLimitRule(); Rule lmr = new LimitMarketRule(); Rule llr = new LimitLimitRule(); rm = new RuleManager(); rm.addRule(mmr); rm.addRule(mlr); rm.addRule(lmr); rm.addRule(llr); }//end static block //--[ MemberMethods ]------------ public TradingState(){} /** * This method tells the state's standard rule manager to * apply all the rules against the order book with a new order * * @returns all Trades made */ public void applyRules(OrderBook ob, Order o) throws TradeClosedException { rm.applyRules(ob,o); } /** * This method tells the state's standard rule manager to * apply all the rules against the order book with a new order * In this case the rules that are executed are run by the Auction Rule * manager. * * @returns all Trades made */ public void bootstrapState(OrderBook ob) throws TradeClosedException { initRM.applyRules(ob, null); } } //end class