public List <DeliveryType> GetAllDeliveryTypes(int month) { CostContext costContext = new CostContext(); List <DeliveryType> deliveryTypes = new List <DeliveryType>(); var mobike = new MotorbikeDelivery(); costContext.SetStrategy(new MotorbikeCostStrategy()); mobike.Cost = costContext.CalculateCost(month); deliveryTypes.Add(mobike); var train = new TrainDelivery(); costContext.SetStrategy(new TrainCostStrategy()); train.Cost = costContext.CalculateCost(month); deliveryTypes.Add(train); var aircraft = new AircraftDelivery(); costContext.SetStrategy(new AircraftCostStrategy()); aircraft.Cost = costContext.CalculateCost(month); deliveryTypes.Add(aircraft); return(deliveryTypes); }
public CostContext cost() { CostContext _localctx = new CostContext(Context, State); EnterRule(_localctx, 2, RULE_cost); int _la; try { EnterOuterAlt(_localctx, 1); { State = 48; Match(COST_BEGIN); State = 49; cost_level(); State = 54; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la == COMMA) { { { State = 50; Match(COMMA); State = 51; cost_level(); } } State = 56; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } State = 57; Match(COST_END); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public CostContext cost() { CostContext _localctx = new CostContext(Context, State); EnterRule(_localctx, 2, RULE_cost); int _la; try { EnterOuterAlt(_localctx, 1); { State = 19; Match(COST_LABEL); State = 23; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la == INTEGER) { { { State = 20; level(); } } State = 25; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } State = 26; Match(NEW_LINE); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public CostItemsController(CostContext context) { _context = context; }