Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Manager engin = new Manager()
            {
                Name = "Engin", Salary = 1000
            };
            Manager salih = new Manager()
            {
                Name = "Salih", Salary = 900
            };

            Worker derin = new Worker()
            {
                Name = "Derin", Salary = 800
            };
            Worker veli = new Worker()
            {
                Name = "Veli", Salary = 800
            };

            engin.Subordinates.Add(salih);
            salih.Subordinates.Add(derin);
            salih.Subordinates.Add(veli);

            OrganisationalStructure organisationalStructure = new OrganisationalStructure(engin);

            PayrollVisitor payrollVisitor = new PayrollVisitor();
            PayRiseVisitor payRiseVisitor = new PayRiseVisitor();


            organisationalStructure.Accept(payrollVisitor);
            organisationalStructure.Accept(payRiseVisitor);

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            //ziyaretçi desene
            // birbirine benzeyen veya hiyerarşik nesnelerin birbirine benzeyen metodlarının biri üzerinden çağrılmasıdır
            Manager managerFatih = new Manager {
                Name = "Fatih", Salary = 1000
            };
            Manager managerEngin = new Manager {
                Name = "Engin", Salary = 900
            };

            Worker workerSalih = new Worker {
                Name = "Salih", Salary = 800
            };
            Worker workerAli = new Worker {
                Name = "Ali", Salary = 700
            };

            managerFatih.Subordinates.Add(managerEngin);
            managerEngin.Subordinates.Add(workerSalih);
            managerEngin.Subordinates.Add(workerAli);

            OrganisationalStructure organisationalStructure = new OrganisationalStructure(managerFatih);
            PayrolVisitor           payrolVisitor           = new PayrolVisitor();
            PayRiseVisitor          payRiseVisitor          = new PayRiseVisitor();

            organisationalStructure.Accept(payrolVisitor);
            organisationalStructure.Accept(payRiseVisitor);

            Console.ReadLine();
        }