Ejemplo n.º 1
0
        static void Main()
        {
            AbstractApprover petar = new Menager();
            AbstractApprover dimitar = new DivisionManager();
            AbstractApprover ivan = new ExecutiveDirector();

            //set successors
            petar.SetSuccessor(dimitar);
            dimitar.SetSuccessor(ivan);

            Order smallOrder = new Order(1, 999.99, "Water delivering");
            petar.ProcessRequest(smallOrder);

            Order mediumOrder = new Order(2, 1001, "Fuel delivering");
            petar.ProcessRequest(mediumOrder);

            Order bigOrder = new Order(3, 9999, "Oil delivering");
            petar.ProcessRequest(bigOrder);

            Order specialOrder = new Order(4, 10001, "Tanker delivering");
            petar.ProcessRequest(specialOrder);

            Order nullOrder = new Order(5, null, "Test null order");
            petar.ProcessRequest(nullOrder);
        }
 public override void ProcessRequest(Order order)
 {
     if (order.Amount < 10000)
     {
         Console.WriteLine("{0} approved order #{1}, for amount of {2}, purpose {3}",
             this.GetType().Name, order.Number, order.Amount, order.Purpose);
     }
     else if (order.Amount != null)
     {
         Console.WriteLine("The amount is exceeding 10 000 units! Please, wait for our special offer!");
     }
     else
     {
         Console.WriteLine("Your order is invalid");
     }
 }
 public override void ProcessRequest(Order order)
 {
     if (order.Amount < 5000)
     {
         Console.WriteLine("{0} approved order #{1}, for amount of {2}, purpose {3}",
             this.GetType().Name, order.Number, order.Amount, order.Purpose);
     }
     else if (order.Amount != null)
     {
         successor.ProcessRequest(order);
     }
     else
     {
         Console.WriteLine("Your order is invalid");
     }
 }
 public abstract void ProcessRequest(Order order);