예제 #1
0
        public static void Main()
        {
            Worker Tom = new Worker("Worker Tom", 5);
            Supervisor Mary = new Supervisor("Supervisor Mary", 6);
            Supervisor Jerry = new Supervisor("Supervisor Jerry", 7);
            Supervisor Bob = new Supervisor("Supervisor Bob", 9);
            Worker Jimmy = new Worker("Worker Jimmy", 8);

            //set up the relationships
            Mary.AddSubordinate(Tom); //Tom works for Mary
            Jerry.AddSubordinate(Mary); //Mary works for Jerry
            Jerry.AddSubordinate(Bob); //Bob works for Jerry
            Bob.AddSubordinate(Jimmy); //Jimmy works for Bob

            //Jerry shows his happiness and asks everyone else to do the same
            if (Jerry is IEmployee)
            {
                (Jerry as IEmployee).ShowHappiness();
            }
                
        }
예제 #2
0
        static void Main(string[] args)
        {
            IEmployee worker1 = new Worker("Alkesh", "Kanshat");

            IEmployee worker2 = new Worker("Serajul", "Kanshat");
            IEmployee worker3 = new Worker("Mophu", "Ajgobi");


            Supervisor safu = new Supervisor("Safu", "Guripara");

            safu.AddEmployee(worker1);
            safu.AddEmployee(worker2);
            safu.AddEmployee(worker3);
            Supervisor esty = new Supervisor("Esty", "Captan bari");

            esty.AddEmployee(safu);


            safu.GetEmployee(1);

            Console.ReadLine();
        }