Exemple #1
0
        public void Run()
        {
            Employees employees = new Employees();

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

            employees.Accept(new IncomeVisitor());
            employees.Accept(new VacationVisitor());
        }
Exemple #2
0
        internal static void Main()
        {
            // Setup employee collection
            var employees = new Employees();
            employees.Attach(new Clerk());
            employees.Attach(new Director());
            employees.Attach(new President());

            // Employees are 'visited'
            employees.Accept(new IncomeVisitor());
            employees.Accept(new VacationVisitor());
        }
        internal static void Main()
        {
            // Setup employee collection
            var employees = new Employees();

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

            // Employees are 'visited'
            employees.Accept(new IncomeVisitor());
            employees.Accept(new VacationVisitor());
        }
        public Client()
        {
            // 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());
        }
        static void Main(string[] args)
        {
            Employees employees = new Employees();

            employees.Attach(new Clerk());
            employees.Attach(new Directory());
            employees.Attach(new President());

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

            Console.ReadKey();
        }
Exemple #6
0
        static void Main(string[] args)
        {
            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());
        }
Exemple #7
0
        public static void Main(string[] args)
        {
            var employees = new Employees();


            employees.Attach(new Clerk("Clerk", 500, 15));
            employees.Attach(new Manager("Manager", 5000, 25));


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


            Console.ReadKey();
        }
Exemple #8
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Main()
        {
            // 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();
        }
Exemple #9
0
        /// <summary>
        /// The Visitor pattern represents an operation to be performed on the elements of an object structure.
        /// Whereas Strategy exposes items to a standardized interface, Visitor details a mechanism by which
        /// objects can accept a reference to another object (the visitor) which exposes an interface that the target
        /// can call upon itself.
        /// </summary>
        /// <param name="args"></param>
        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();
        }
Exemple #10
0
        internal static void Main()
        {
            // Greshno, tai kato ne e rabota na Main metoda da vdiga zaplatatata na employee
            // Zatova se pravi IncomeVisitor, koito ima pravomostiata da ia vdiga
            var employee = new Clerk();
            employee.Income += 1000;

            // Setup employee collection
            var employees = new Employees();
            employees.Attach(new Clerk());
            employees.Attach(new Director());
            employees.Attach(new President());

            // Employees are 'visited'
            employees.Accept(new IncomeVisitor());
            employees.Accept(new VacationVisitor());
        }
Exemple #11
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.ToRewardAllEmployees(new IncomeVisitor(1.1));   // Everyone get a raise of 10%
            e.ToRewardAllEmployees(new VacationVisitor(2));   // Everyone get 2 days leave

            Console.ReadKey();
        }
Exemple #12
0
        /// <resumen>

        /// Punto de entrada en la aplicación de consola.

        /// </resumen>

        static void Main(string [] args)
        {
            // Configurar colección de empleados

            Employees e = new Employees();

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

            // Los empleados son 'visitados'

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

            // Espera al usuario

            Console.ReadKey();
        }
Exemple #13
0
        static void Main(string[] args)
        {
            //Object structure
            Employees employees = new Employees();

            //Elements
            Element clerk    = new Clerk("Edward", 500, 6);
            Element director = new Director("Jonathan", 600, 8);

            //Visitors
            IVisitor incomeVisitor   = new IncomeVisitor();
            IVisitor vacationVisitor = new VacationVisitor();

            // Attach elements to the object structure
            employees.Attach(clerk);
            employees.Attach(director);

            //Perform operation of different visitors.
            employees.Accept(incomeVisitor);
            employees.Accept(vacationVisitor);
        }
        public static void Run()
        {
            Console.WriteLine("This real-world code demonstrates the Visitor pattern in which two objects traverse a list of Employees and performs the same operation on each Employee. The two visitor objects define different operations -- one adjusts vacation days and the other income.\n");
            Employees e = new Employees();

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

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

            /*
             * Clerk Hank's new income: $27,500.00
             * Director Elly's new income: $38,500.00
             * President Dick's new income: $49,500.00
             *
             * Clerk Hank's new vacation days: 17
             * Director Elly's new vacation days: 19
             * President Dick's new vacation days: 24
             */
        }
        static void Main(string[] args)
        {
            Employee xz  = new Engineer("小张", "工业设计部", 3000.0, 10);
            Employee xw  = new Engineer("小王", "工业设计部", 3100.0, 11);
            Employee xc  = new Engineer("小张", "营销零售部", 2800.0, 5);
            Employee xl  = new Engineer("小李", "营销零售部", 2900.0, 4);
            Employee xzh = new Engineer("小周", "财务管理部", 3200.0, 3);

            Employees employees = new Employees();

            employees.Attach(xz);
            employees.Attach(xw);
            employees.Attach(xc);
            employees.Attach(xl);
            employees.Attach(xzh);

            Visitor incomeVisitor   = new IncomeVisitor();
            Visitor vacationVisitor = new VacationVisitor();

            employees.Accept(incomeVisitor);
            employees.Accept(vacationVisitor);

            Console.ReadKey();
        }
Exemple #16
0
        private void button6_Click(object sender, EventArgs e)
        {
            Employees empleados = new Employees();
            empleados.Attach(new Director());

            empleados.Accept(new VisitorIngreso());
        }