コード例 #1
0
        static void Main(string[] args)
        {
            Manager ahmet = new Manager {
                Name = "Ahmet", Salary = 1000
            };
            Manager burak = new Manager {
                Name = "Burak", Salary = 900
            };

            Worker tuğra = new Worker {
                Name = "Tuğra", Salary = 800
            };
            Worker berkay = new Worker {
                Name = "berkay", Salary = 800
            };

            ahmet.Subordinates.Add(burak);
            burak.Subordinates.Add(tuğra);
            burak.Subordinates.Add(berkay);

            OrganisationalStructure organisationalStructure = new OrganisationalStructure(ahmet);

            PayrollVisitor payrollVisitor = new PayrollVisitor();
            PayriseVisitor payriseVisitor = new PayriseVisitor();

            organisationalStructure.Accept(payrollVisitor);
            organisationalStructure.Accept(payriseVisitor);

            Console.ReadLine();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Manager manager = new Manager {
                Name = "engin", Salary = 1000
            };
            Manager manager2 = new Manager {
                Name = "salih", Salary = 900
            };

            Worker worker = new Worker {
                Name = "derin", Salary = 800
            };
            Worker worker2 = new Worker {
                Name = "ali", Salary = 800
            };

            manager.Subordinates.Add(manager2);
            manager2.Subordinates.Add(worker2);

            OrganisationalStructure organisationalStructure = new OrganisationalStructure(manager);
            PayrollVisitor          payrollVisitor          = new PayrollVisitor();
            PayRise payRise = new PayRise();

            organisationalStructure.Accept(payrollVisitor);
            organisationalStructure.Accept(payRise);

            Console.ReadLine();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Manager ali = new Manager()
            {
                EmployeeName = "Ali", Salary = 10000
            };
            Manager veli = new Manager()
            {
                EmployeeName = "Veli", Salary = 9000
            };

            Worker mahmut = new Worker()
            {
                EmployeeName = "Mahmut", Salary = 7000
            };
            Worker zeyno = new Worker()
            {
                EmployeeName = "Zeyno", Salary = 7100
            };

            ali.subordinates.Add(veli);
            veli.subordinates.Add(mahmut);
            veli.subordinates.Add(zeyno);

            OrganizationService service = new OrganizationService(ali);

            PayrollVisitor  payrollVisitor  = new PayrollVisitor();
            PayRaiseVisitor payRaiseVisitor = new PayRaiseVisitor();

            service.Accept(payrollVisitor);
            service.Accept(payRaiseVisitor);

            Console.Read();
        }
コード例 #4
0
        //bir şirketin maaş artışı ve ödeme işlemlerini visitor deseni ile baz alan sistem kurmak için şunları yapacağız
        static void Main(string[] args)
        {
            //ana kısımda

            Manager yusuf = new Manager {
                Name = "Yusuf", Salary = 1000
            };                                                             //yöneticileri tanımladık
            Manager kadir = new Manager {
                Name = "Kadir", Salary = 950
            };

            Worker rabia = new Worker {
                Name = "Rabia", Salary = 500
            };                                                          //işçileri tanımladık
            Worker recep = new Worker {
                Name = "Recep", Salary = 650
            };

            yusuf.Subordinates.Add(kadir); //alt çalışanları tanımladık
            kadir.Subordinates.Add(rabia);
            kadir.Subordinates.Add(recep);

            OrganisationalStructure organisationalStructure = new OrganisationalStructure(yusuf); //ödeme ve maaş sistemini tanımladık
            PayrollVisitor          payrollVisitor          = new PayrollVisitor();
            PayriseVisitor          payriseVisitor          = new PayriseVisitor();

            organisationalStructure.Accept(payrollVisitor); //maaş ve ödemeleri arttırmayı onayladık
            organisationalStructure.Accept(payriseVisitor);

            Console.ReadLine();
        }
コード例 #5
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 ali = new Worker {
                Name = "Ali", Salary = 800
            };

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



            OrganisationalStructure organisationalStructure = new OrganisationalStructure(engin);

            PayrollVisitor payrollVisitor = new PayrollVisitor();
            PayriseVisitor payriseVisitor = new PayriseVisitor();

            organisationalStructure.Accept(payrollVisitor);
            organisationalStructure.Accept(payriseVisitor);
            Console.ReadLine();
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: cmlbrnc/DesignPatterns
        static void Main(string[] args)
        {
            Manager jack = new Manager {
                Name = "Jack", Salary = 4000
            };
            Manager john = new Manager {
                Name = "John", Salary = 3000
            };

            Worker amy = new Worker {
                Name = "amy", Salary = 2500
            };
            Worker peter = new Worker {
                Name = "Peter", Salary = 1500
            };

            jack.Subordinates.Add(john);
            john.Subordinates.Add(amy);
            john.Subordinates.Add(peter);

            OrganizationalStructure organizationalStructure = new OrganizationalStructure(jack);

            PayrollVisitor payrollVisitor = new PayrollVisitor();

            Payrise payrise = new Payrise();

            organizationalStructure.Accept(payrollVisitor);

            organizationalStructure.Accept(payrise);

            Console.ReadLine();
        }
コード例 #7
0
        static void Main(string[] args)
        {
            Manager ugur = new Manager {
                Name = "Uğur", Salary = 2000
            };
            Manager yusuf = new Manager {
                Name = "yusuf", Salary = 2000
            };

            Worker leyla = new Worker {
                Name = "Leyla", Salary = 1500
            };
            Worker kamil = new Worker {
                Name = "Kamil", Salary = 1500
            };

            ugur.subordi.Add(yusuf);
            ugur.subordi.Add(leyla);
            yusuf.subordi.Add(kamil);

            OrganisationalStructure org            = new OrganisationalStructure(ugur);
            PayrollVisitor          payrollVisitor = new PayrollVisitor();
            PayriseVisitor          payriseVisitor = new PayriseVisitor();

            org.Accept(payrollVisitor);
            org.Accept(payriseVisitor);
        }
コード例 #8
0
        static void Main(string[] args)
        {
            Manager eray = new Manager {
                Name = "Eray", Salary = 1000
            };
            Manager hakan = new Manager {
                Name = "Hakan", Salary = 1100
            };

            Calisan semih = new Calisan {
                Name = "Semih", Salary = 800
            };
            Calisan mustafa = new Calisan {
                Name = "Mustafa", Salary = 800
            };

            eray.employeeBases.Add(hakan);
            hakan.employeeBases.Add(semih);
            hakan.employeeBases.Add(mustafa);

            OrganisationalStructure organisational = new OrganisationalStructure(eray);

            PayrollVisitor payrollVisitor = new PayrollVisitor();
            Payrise        payriseVisitor = new Payrise();

            organisational.Accept(payrollVisitor);
            organisational.Accept(payriseVisitor);
            Console.ReadLine();
        }
コード例 #9
0
        static void Main(string[] args)
        {
            Manager ceren = new Manager {
                Name = "Ceren", Salary = 1000
            };
            Manager ezgi = new Manager {
                Name = "Ezgi", Salary = 900
            };

            Worker derin = new Worker {
                Name = "Derin", Salary = 800
            };
            Worker ali = new Worker {
                Name = "Ali", Salary = 800
            };

            ezgi.Subordinates.Add(ceren);
            ceren.Subordinates.Add(derin);
            ceren.Subordinates.Add(ali);

            OrganisationalStructure organisationalStructure = new OrganisationalStructure(ezgi);

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

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

            Console.ReadLine();
        }
コード例 #10
0
        static void Main(string[] args)
        {
            Manager gokay = new Manager {
                Name = "Gökay", Salary = 1000
            };
            Manager gokhan = new Manager {
                Name = "Gökhan", Salary = 900
            };

            Worker kaan = new Worker {
                Name = "Kaan", Salary = 800
            };
            Worker ali = new Worker {
                Name = "Ali", Salary = 800
            };

            gokay.Subordinates.Add(gokhan);
            gokhan.Subordinates.Add(kaan);
            gokhan.Subordinates.Add(ali);

            OrganisationalStructure organisationalStructure = new OrganisationalStructure(gokay);

            PayrollVisitor payrollVisitor = new PayrollVisitor();
            PayriseVisitor payriseVisitor = new PayriseVisitor();

            organisationalStructure.Accept(payrollVisitor);
            organisationalStructure.Accept(payriseVisitor);

            Console.ReadLine();
        }
コード例 #11
0
        static void Main(string[] args)
        {
            Manager umut = new Manager {
                Name = "Umut", Salary = 1100
            };
            Manager arif = new Manager {
                Name = "Arif", Salary = 800
            };

            Worker ahmet = new Worker {
                Name = "Ahmet", Salary = 600
            };
            Worker mehmet = new Worker {
                Name = "Mehmet", Salary = 600
            };

            umut.Subordinates.Add(arif);
            arif.Subordinates.Add(ahmet);
            arif.Subordinates.Add(mehmet);

            OrganisationalStructure organisationalStructure = new OrganisationalStructure(umut);

            PayrollVisitor payrollVisitor = new PayrollVisitor();
            Payrise        payrise        = new Payrise();

            organisationalStructure.Accept(payrollVisitor);
            organisationalStructure.Accept(payrise);

            Console.ReadLine();
        }
コード例 #12
0
        static void Main(string[] args)
        {
            Manager muhsin = new Manager()
            {
                Name = "Muhsin", Salary = 1000
            };
            Manager ahmet = new Manager()
            {
                Name = "Ahmet", Salary = 1000
            };

            Worker selin = new Worker()
            {
                Name = "Selin", Salary = 800
            };
            Worker ufuk = new Worker()
            {
                Name = "Ufuk", Salary = 800
            };

            muhsin.SubOrdinates.Add(selin);
            ahmet.SubOrdinates.Add(ufuk);

            OrganitionalStructure organitionalStructure = new OrganitionalStructure(muhsin);

            PayrollVisitor payrollVisitor = new PayrollVisitor();
            PayriseVisitor payriseVisitor = new PayriseVisitor();

            organitionalStructure.Accept(payrollVisitor);
            organitionalStructure.Accept(payriseVisitor);
        }
コード例 #13
0
        static void Main(string[] args)
        {
            Manager bob = new Manager();

            bob.Name          = "Bob";
            bob.MonthlySalary = 5000;

            Manager sue = new Manager();

            sue.Name          = "Sue";
            sue.MonthlySalary = 4000;

            Worker jim = new Worker();

            jim.Name          = "Jim";
            jim.MonthlySalary = 2000;

            Worker tom = new Worker();

            tom.Name          = "Tom";
            tom.MonthlySalary = 1800;

            Worker mel = new Worker();

            mel.Name          = "Mel";
            mel.MonthlySalary = 1900;

            bob.Subordinates.Add(sue);
            bob.Subordinates.Add(jim);
            sue.Subordinates.Add(tom);
            sue.Subordinates.Add(mel);

            OrganisationalStructure org = new OrganisationalStructure(bob);

            PayrollVisitor payroll = new PayrollVisitor();
            PayriseVisitor payrise = new PayriseVisitor(0.05);

            org.Accept(payroll);
            org.Accept(payrise);
            org.Accept(payroll);

            Console.WriteLine("Total pay increase = {0}.", payrise.TotalIncrease);

            Console.Read();
        }
コード例 #14
0
        static void Main(string[] args)
        {
            Manager ahmet = new Manager
            {
                Name   = "Ahmet",
                Salary = 1000
            };
            Manager aygn = new Manager
            {
                Name   = "Aygün",
                Salary = 1100
            };
            Manager can = new Manager
            {
                Name   = "can",
                Salary = 900
            };
            Worker leyla = new Worker
            {
                Name   = "Leyla",
                Salary = 800
            };
            Worker ali = new Worker
            {
                Name   = "Ali",
                Salary = 800
            };

            ahmet.Subordinates.Add(can);
            can.Subordinates.Add(aygn);
            aygn.Subordinates.Add(leyla);
            aygn.Subordinates.Add(ali);

            OrganisationalStructure organisationalStructure = new OrganisationalStructure(ahmet);
            PayrollVisitor          payrollVisitor          = new PayrollVisitor();
            PayriseVisitor          payriseVisitor          = new PayriseVisitor();

            organisationalStructure.Accept(payrollVisitor);
            organisationalStructure.Accept(payriseVisitor);
            Console.ReadKey();
        }
コード例 #15
0
        static void Main(string[] args)
        {
            /*Genel olarak birbirine benziyen ve hiyerarşi nesnelerin aynı methodunun biri üzerinden çağırılması.*/

            Manager manager1 = new Manager {
                Name = "okan", Salary = 1000
            };
            Manager manager2 = new Manager {
                Name = "cenk", Salary = 900
            };
            Worker worker = new Worker {
                Name = "Eleman", Salary = 500
            };
            Worker worker1 = new Worker {
                Name = "Eleman1", Salary = 500
            };
            Worker worker2 = new Worker {
                Name = "Eleman2", Salary = 500
            };

            manager1.Subordinates.Add(worker);
            manager1.Subordinates.Add(worker1);
            manager2.Subordinates.Add(worker2);

            OrganisationalStructure organisationalStructure = new OrganisationalStructure(manager1);

            PayrollVisitor payrollVisitor = new PayrollVisitor();
            Payrise        payrise        = new Payrise();

            organisationalStructure.Accept(payrollVisitor);
            organisationalStructure.Accept(payrise);



            Console.ReadLine();
        }
コード例 #16
0
 public void Accept(PayrollVisitor payrollVisitor)
 {
     Employee.Accept(payrollVisitor);
 }