public void Process(ReturnOrder order) { var process = ReturnProcessFactory.CreateFrom(order); process.Process(order); Console.WriteLine(order.AmountToRefund); }
static void Main(string[] args) { ReturnOrder o1 = new ReturnOrder { PricePaid = 10, PostageCost = 10, Action = ReturnAction.FaultyReturn }; ReturnOrder o2 = new ReturnOrder { PricePaid = 10, PostageCost = 10, Action = ReturnAction.NoQuibblesReturn }; ReturnService rs = new ReturnService(); rs.Process(o1); rs.Process(o2); Console.ReadLine(); }
public static ReturnProcessTemplate CreateFrom(ReturnOrder order) { ReturnProcessTemplate template; switch (order.Action) { case ReturnAction.FaultyReturn: template = new FaultyReturnProcess(); break; case ReturnAction.NoQuibblesReturn: template = new NoQuibblesReturnProcess(); break; default: throw new NotImplementedException("no action found for this return order"); } return(template); }
protected override void GenerateReturnTransactionFor(ReturnOrder order) { Console.WriteLine("transaction generated for no quibbles return...."); }
protected override void CalculateRefundFor(ReturnOrder order) { order.AmountToRefund = order.PricePaid; }
public void Process(ReturnOrder order) { this.CalculateRefundFor(order); this.GenerateReturnTransactionFor(order); }
protected abstract void GenerateReturnTransactionFor(ReturnOrder order);
protected abstract void CalculateRefundFor(ReturnOrder order);