コード例 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var william = new ExpenseHandler(new Employee("Will", 0));
            var mary    = new ExpenseHandler(new Employee("Mary", 1000));
            var victor  = new ExpenseHandler(new Employee("Victor", 5000));

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

            IExpenseReport   report   = new ExpenseReport(1500);
            ApprovalResponse response = william.Approve(report);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            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(5000)));
            ExpenseHandler paula   = new ExpenseHandler(new Employee("Paula President", new Decimal(20000)));

            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);

                WriteLine($"The request was {response}.");
                ReadLine();
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            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(5000)));
            ExpenseHandler Paula   = new ExpenseHandler(new Employee("Paula Pres", new decimal(20000)));

            William.RegisterNext(Mary);
            Mary.RegisterNext(Victor);
            Victor.RegisterNext(Paula);

            Decimal expenseReportAmount;

            do
            {
                Console.Write("Expense Report Amout: ");
                Decimal.TryParse(Console.ReadLine(), out expenseReportAmount);
                IExpenseReport   expense  = new ExpenseReport(expenseReportAmount);
                ApprovalResponse response = William.Approve(expense);
                Console.WriteLine($"The request was {response}");

                Console.WriteLine("Again? ");
            } while (Console.ReadLine() != "");
        }