Exemplo n.º 1
0
        private static void RequestCheapExpense(ExpenseHandler manager)
        {
            IExpenseReport   cheapExpenseReport   = new ExpenseReport(500);
            ApprovalResponse cheapExpenseResponse = manager.Approve(cheapExpenseReport);

            Console.WriteLine("The request for {0} was {1}.", cheapExpenseReport.Total, cheapExpenseResponse);
        }
Exemplo n.º 2
0
        private static void RequestMildlyCheapExpense(ExpenseHandler manager)
        {
            IExpenseReport   mildlyCheapExpenseReport  = new ExpenseReport(1250);
            ApprovalResponse mildlyCheapExpenseReponse = manager.Approve(mildlyCheapExpenseReport);

            Console.WriteLine("The request for {0} was {1}.", mildlyCheapExpenseReport.Total, mildlyCheapExpenseReponse);
        }
Exemplo n.º 3
0
        private static void RequestRatherExpensiveExpense(ExpenseHandler manager)
        {
            IExpenseReport   ratherExpensiveExpenseReport = new ExpenseReport(5500);
            ApprovalResponse ratherExpensiveResponse      = manager.Approve(ratherExpensiveExpenseReport);

            Console.WriteLine("The request for {0} was {1}.", ratherExpensiveExpenseReport.Total, ratherExpensiveResponse);
        }
Exemplo n.º 4
0
        private static void RequestStupidlyExpensiveExpense(ExpenseHandler manager)
        {
            IExpenseReport   stupidlyExpensiveExpenseReport = new ExpenseReport(25000);
            ApprovalResponse stupidlyExpensiveResponse      = manager.Approve(stupidlyExpensiveExpenseReport);

            Console.WriteLine("The request for {0} was {1}.", stupidlyExpensiveExpenseReport.Total, stupidlyExpensiveResponse);
        }
Exemplo n.º 5
0
        private static ExpenseHandler CreateReportingChain()
        {
            ExpenseHandler manager       = new ExpenseHandler(new Employee("Manager", decimal.Zero));
            ExpenseHandler director      = new ExpenseHandler(new Employee("Director", new decimal(1000)));
            ExpenseHandler vicePresident = new ExpenseHandler(new Employee("Vice President", new decimal(5000)));
            ExpenseHandler president     = new ExpenseHandler(new Employee("President", new decimal(20000)));

            manager.RegisterNext(director);
            director.RegisterNext(vicePresident);
            vicePresident.RegisterNext(president);

            return(manager);
        }
Exemplo n.º 6
0
        static void Main()
        {
            ExpenseHandler william = new ExpenseHandler(new Employee("William Worker", decimal.Zero));
            ExpenseHandler mary    = new ExpenseHandler(new Employee("Mary Manager", new decimal(1000)));
            ExpenseHandler victor  = new ExpenseHandler(new Employee("Victor Vicepres", new decimal(2000)));
            ExpenseHandler paula   = new ExpenseHandler(new Employee("Paula President", new decimal(5000)));

            william.RegisterNext(mary);
            mary.RegisterNext(victor);
            victor.RegisterNext(paula);

            decimal expenseReportAmount;

            if (ConsoleInput.TryReadDecimal("Expense Report Amount: ", out expenseReportAmount))
            {
                IExpenseReport expense = new ExpenseReport(expenseReportAmount);

                ApprovalResponse response = william.Approve(expense);

                Console.WriteLine("The request was {0}.", response);
            }

            Console.ReadKey();
        }