コード例 #1
0
ファイル: Program.cs プロジェクト: deryadok/DesignPatterns
        static void Main(string[] args)
        {
            CultureInfo.CurrentCulture = new CultureInfo("en-US");
            Employees emp = new Employees();

            emp.Attach(new Clerk());
            emp.Attach(new Director());
            emp.Attach(new President());

            emp.Accept(new IncomeVisitor());
            emp.Accept(new VacationVisitor());

            Console.ReadKey();
        }
コード例 #2
0
        static void Employees()
        {
            var employees = new Employees();

            employees.Attach(new LineCook());
            employees.Attach(new HeadChef());
            var gm = new GeneralManager();

            employees.Attach(gm);

            employees.Accept(new IncomeVisitor());

            employees.Detach(gm);

            employees.Accept(new PaidTimeOffVisitor());
        }
コード例 #3
0
        static void Main(string[] args)
        {
            // Setup employee collection
            Employees e = new Employees();

            e.Attach(new Clerk());
            e.Attach(new Director());
            e.Attach(new President());

            // Employees are 'visited'
            e.Accept(new IncomeVisitor());
            e.Accept(new VacationVisitor());

            // Wait for user
            Console.ReadKey();
        }
コード例 #4
0
        public void Test()
        {
            // Setup employee collection
            Employees e = new Employees();

            e.Attach(new Clerk());
            e.Attach(new Director());
            e.Attach(new President());

            // Employees are 'visited'
            e.Accept(new IncomeVisitor());
            e.Accept(new VacationVisitor());

            // Wait for user
            Console.Read();
        }
コード例 #5
0
        static void Main(string[] args)
        {
            // Who are my employees?
            Employees e = new Employees();

            e.Attach(new LineCook());
            e.Attach(new HeadChef());
            e.Attach(new GeneralManager());

            // Employees are visited, giving them 10% raises
            // and 3 extra paid time off days.
            e.Accept(new IncomeVisitor());
            e.Accept(new PaidTimeOffVisitor());

            Console.ReadKey();
        }
コード例 #6
0
        private static void Main()
        {
            var employees = new Employees();
            employees.Attach(new Clerk("Stamat", 1231.123, 21));
            employees.Attach(new Director("Nafarforii", 2231.123, 26));
            employees.Attach(new President("Gazobarov", 3231.123, 30));

            Console.WriteLine("Initial status of employees");
            var print1 = employees.GetEmployees();
            print1.ForEach(Console.WriteLine);

            employees.Accept(new IncomeVisitor());
            employees.Accept(new VacationVisitor());

            Console.WriteLine();
            Console.WriteLine("Change status of employees");
            print1 = employees.GetEmployees();
            print1.ForEach(Console.WriteLine);
        }