static void MainOLD()
        {
            Employees employees = new Employees();

            Employee jesse = new DistributionManager();
            Employee walt  = new Cook();

            IVisitor payRise       = new IncomeVisitor();
            IVisitor extraVacation = new VacationVisitor();

            employees.Add(jesse);
            employees.Add(walt);

            employees.Accept(payRise);
            walt.Accept(extraVacation);
        }
示例#2
0
        static void Main(string[] args)
        {
            // Setup structure
            ElementStructure structure = new ElementStructure();
            structure.Attach(new Employee { Name = "Risto Reipas", Salary = 3000, VacationDays = 20 });
            structure.Attach(new Employee { Name = "Erno Perälä", Salary = 3200, VacationDays = 40 });
            structure.Attach(new Employee { Name = "Sauli Niinistö", Salary = 13000, VacationDays = 2 });

            // Create visitor objects
            IVisitor salaryFairy = new SalaryVisitor();
            IVisitor vacationFairy = new VacationVisitor();

            // Structure accepting visitors
            structure.Accept(salaryFairy);
            structure.Accept(vacationFairy);

            // Wait for user
            Console.ReadLine();
        }
  public static void Main( string[] args )
  {
    // Setup employee collection
    Employees e = new Employees();
    e.Attach( new Employee( "Hank", 25000.0, 14 ) );
    e.Attach( new Employee( "Elly", 35000.0, 16 ) );
    e.Attach( new Employee( "Dick", 45000.0, 21 ) );

    // Create two visitors
    IncomeVisitor v1 = new IncomeVisitor();
    VacationVisitor v2 = new VacationVisitor();

    // Employees are visited
    e.Accept( v1 );
    e.Accept( v2 );

  }
示例#4
0
    public VisitorApp()
    {
        Employees e = new Employees();
        e.Attach(new Employee("Hank", 25000, 14));
        e.Attach(new Employee("Elly", 35000, 16));
        e.Attach(new Employee("Dick", 45000, 21));

        IncomeVisitor v1 = new IncomeVisitor();
        VacationVisitor v2 = new VacationVisitor();

        e.Accept(v1);
        e.Accept(v2);
    }