Exemplo n.º 1
1
        public static void PromoteEmployee(List<Employee> empList, IsPromotable isEligibleToPtomote)
        {
            foreach (Employee emp in empList)
            {
                if (isEligibleToPtomote(emp))
                {
                    Console.WriteLine(emp.Nom + " is Promoted");
                }

            }
        }
Exemplo n.º 2
1
 public static void PromotEmployee(List<Employee> listEmployee,IsPromotable delPromote)
 {
     foreach (Employee emp in listEmployee)
     {
         //if(emp.YearsOfExp>=7)
         if(delPromote(emp))
         {
             Console.WriteLine("Congratulation !!! {0} you are Promoted!",emp.Name);
         }
     }
 }
Exemplo n.º 3
1
        static void Main(string[] args)
        {
            List<Employee> emplist = new List<Employee>();
            emplist.Add(new Employee() { ID = 101, Name = "Purvin", Salary = 5000, Experience = 5 });
            emplist.Add(new Employee() { ID = 102, Name = "Purvin1", Salary = 4000, Experience = 4 });
            emplist.Add(new Employee() { ID = 103, Name = "Purvin2", Salary = 6000, Experience = 6 });
            emplist.Add(new Employee() { ID = 104, Name = "Purvin3", Salary = 3000, Experience = 3 });
            IsPromotable isPromotable = new IsPromotable(Promote);

            Employee.PromoteEmployee(emplist,isPromotable);
            Console.ReadLine();
        }
Exemplo n.º 4
1
        static void Main(string[] args)
        {
            #region 1.C Use delegate to de couple the logic of promoting the employee.
            List<Employee> empList = new List<Employee>();
            empList.Add(new Employee() { ID = 101, Name = "Anand", Salary = 4000, Experience = 3 });
            empList.Add(new Employee() { ID = 102, Name = "Praveen", Salary = 5000, Experience = 5 });
            empList.Add(new Employee() { ID = 103, Name = "Anoop", Salary = 6000, Experience = 4 });
            empList.Add(new Employee() { ID = 104, Name = "Uttam", Salary = 8000, Experience = 9 });

            IsPromotable isProtable = new IsPromotable(Promote);

            Employee.PromoteEmployee(empList, isProtable);

            #endregion

            #region 2.B Use delegate and lamda expression while calling it.
            //// lamda expression is basically work on delegates. So we can remove the creating delegate object and creating the function.
            List<Customer> custList = new List<Customer>();
            custList.Add(new Customer() { Name = "Ryan Lim", PurchaseAmount = 1000 });
            custList.Add(new Customer() { Name = "Jimmy Leong", PurchaseAmount = 20000 });
            custList.Add(new Customer() { Name = "Zech Lim", PurchaseAmount = 40000 });
            custList.Add(new Customer() { Name = "John read", PurchaseAmount = 6000 });

            // Here we are using lamda expression, for logic of valuable customer rather than creating a fucntion for delegate.
            Customer.IsValuableCustomer(custList, cust => cust.PurchaseAmount >= 10000);
            #endregion

            #region Example
            Voter v = new Voter();
            v.Age = 20;
            v.LetsVote(v, voter => voter.Age >= 18);

            Example_1 ex = new Example_1();
            ex.ExampleMethod();

            #endregion

            Console.ReadKey();
        }
Exemplo n.º 5
1
 //The following is not reusable, b/c hardcoded for experience. Could want to run for Salary etc.
 public static void PromoteEmployee(List<Employee> employeeList, IsPromotable IsElligibleToPromote) //This function is taking another function as param
 {
     foreach (Employee employee in employeeList)
     {
         if (IsElligibleToPromote(employee))
         {
             Console.WriteLine(employee.Name + " promoted");
         }
     }
 }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            List <Employee> empList = new List <Employee>();

            empList.Add(new Employee()
            {
                ID = 101, Name = "Mary", Salary = 5000, Experience = 5
            });
            empList.Add(new Employee()
            {
                ID = 101, Name = "Mike", Salary = 4000, Experience = 4
            });
            empList.Add(new Employee()
            {
                ID = 101, Name = "John", Salary = 6000, Experience = 6
            });
            empList.Add(new Employee()
            {
                ID = 101, Name = "Todd", Salary = 3000, Experience = 3
            });
            IsPromotable isPromotable1 = new IsPromotable(Promote);

            /* we can aslo achieve this using lambda expression*/
            Employee.PromoteEmployee(empList, isPromotable1);
            System.Console.ReadLine();
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            List <Employee> empList = new List <Employee>();

            empList.Add(new Employee()
            {
                ID = 101, Name = "Aji", Salary = 5000, Experience = 5
            });
            empList.Add(new Employee()
            {
                ID = 102, Name = "adi", Salary = 4000, Experience = 4
            });
            empList.Add(new Employee()
            {
                ID = 103, Name = "mike", Salary = 6000, Experience = 6
            });
            empList.Add(new Employee()
            {
                ID = 104, Name = "mari", Salary = 3000, Experience = 3
            });

            IsPromotable promoted = new IsPromotable(Promote);
            IsPromotable naikGaji = new IsPromotable(KenaikanGaji);

            Employee.PromoteEmployee(empList, promoted);
            // kita juga bisa menggunakan lambda expression
            Employee.NaikGaji(empList, emp => emp.Salary < 5000);
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            Employee employeeA = new Employee("vishal", 123, 5000, 5);

            Employee employeeB = new Employee("Lalchand", 124, 1000, 3);

            Employee employeeC = new Employee("Kapoorchand", 125, 3000, 2);

            Employee employeeD = new Employee("Suresh", 126, 4000, 6);

            Employee employeeE = new Employee("Ramesh", 127, 9000, 10);

            List <Employee> employeeList = new List <Employee>();

            employeeList.Add(employeeA);
            employeeList.Add(employeeB);
            employeeList.Add(employeeC);
            employeeList.Add(employeeD);
            employeeList.Add(employeeE);

            IsPromotable isPromotable = new IsPromotable(Promote);

            Employee.PromoteEmployee(employeeList, isPromotable);

            Console.ReadLine();
        }
Exemplo n.º 9
0
        public static void Hello(string strMessage)
        {
            Console.WriteLine(strMessage);

            List <Employee> empList = new List <Employee>();

            empList.Add(new Employee()
            {
                ID = 101, name = "Mary", salary = 100000, experience = 3
            });
            empList.Add(new Employee()
            {
                ID = 102, name = "John", salary = 60000, experience = 6
            });
            empList.Add(new Employee()
            {
                ID = 103, name = "Mike", salary = 40000, experience = 7
            });
            empList.Add(new Employee()
            {
                ID = 104, name = "Tomm", salary = 30000, experience = 2
            });

            IsPromotable isPromotable = new IsPromotable(Promote);


            Employee.PromoteEmployee(empList, isPromotable);
            Console.WriteLine("********************************************");
            Employee.NewSalary(empList, emp => emp.salary <= 50000);
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            DelegateMethod dm = new DelegateMethod(Message);

            dm("Hello from delegate");

            List <Employee> empList = new List <Employee>()
            {
                new Employee {
                    Id = 101, Name = "Abhilash", Salary = 60000, Experience = 6.9
                },
                new Employee {
                    Id = 102, Name = "Abhishek", Salary = 80000, Experience = 5.0
                },
                new Employee {
                    Id = 103, Name = "Ajay", Salary = 40000, Experience = 4.0
                },
                new Employee {
                    Id = 104, Name = "Arjun", Salary = 70000, Experience = 9.2
                },
                new Employee {
                    Id = 105, Name = "Abhijeeth", Salary = 10000, Experience = 1.7
                },
            };

            IsPromotable dobj = new IsPromotable(promoteEmp);



            Employee.PromoteEmployee(empList, dobj);
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            List <Employee> empList = new List <Employee>()
            {
                new Employee {
                    ID = 100, Name = "Madame", Salary = 5000, Experience = 5
                },
                new Employee {
                    ID = 101, Name = "Baba", Salary = 4000, Experience = 4
                },
                new Employee {
                    ID = 102, Name = "Strumpan", Salary = 6000, Experience = 6
                },
                new Employee {
                    ID = 103, Name = "Troj", Salary = 3000, Experience = 3
                }
            };

            // The instance of the delegate, which points to the methode Promote(), is created here in the Main method in the Program class.
            // The method Promote() must also take an Employee as the argument, and return a bool type, just like the delegate IsPromotable (see
            // below).
            IsPromotable delIsPromotable = new IsPromotable(Promote);

            // Calling the method PromoteEmployee() in the Employee class, with our list of employees, empList, and our instance of the delegate
            // IsPromotable, delIsPromotable, as the arguments passed in.
            Employee.PromoteEmployee(empList, delIsPromotable);
        }
    public static void Main(string[] args)
    {
        List <Employee> empList = new List <Employee>();

        empList.Add(new Employee()
        {
            ID         = 101,
            Name       = "Test1",
            Salary     = 5000,
            Experience = 5
        });

        empList.Add(new Employee()
        {
            ID         = 101,
            Name       = "Test2",
            Salary     = 2000,
            Experience = 1
        });

        empList.Add(new Employee()
        {
            ID         = 101,
            Name       = "Test3",
            Salary     = 4000,
            Experience = 4
        });

        IsPromotable isPromotable = new IsPromotable(Promote);

        Employee.PromoteEmployee(empList, isPromotable);
    }
        public static void Main(string[] args)
        {
            //Generics
            List <Employee> employeeList = new List <Employee>();

            employeeList.Add(new Employee()
            {
                ID = 001, Name = "Harvey", Salary = 100000, Experience = 10
            });
            employeeList.Add(new Employee()
            {
                ID = 002, Name = "Yumi", Salary = 100000, Experience = 8
            });
            employeeList.Add(new Employee()
            {
                ID = 003, Name = "Yugito", Salary = 50000, Experience = 4
            });
            employeeList.Add(new Employee()
            {
                ID = 004, Name = "Yuki", Salary = 1000000, Experience = 2
            });

            //Create an instance of the delegate. In the constructor, the target method must be specified
            IsPromotable promotable = new IsPromotable(Promote);

            //Pass paramaters with delegate to the method of another class that must be re-used
            Employee.PromoteEmployee(employeeList, promotable);
        }
Exemplo n.º 14
0
    public static void Main()
    {
        List <Employee> empList = new List <Employee>();

        empList.Add(new Employee()
        {
            ID = 101, Name = "Mary", Salary = 5000, Experience = 5
        });
        empList.Add(new Employee()
        {
            ID = 101, Name = "Mike", Salary = 4000, Experience = 4
        });
        empList.Add(new Employee()
        {
            ID = 101, Name = "John", Salary = 6000, Experience = 6
        });
        empList.Add(new Employee()
        {
            ID = 101, Name = "Todd", Salary = 3000, Experience = 3
        });

        //Obsolete invoke now
        //Employee.PromoteEmployee(empList);


        IsPromotable isPromotable = new IsPromotable(Promote);

        Employee.PromoteEmployee(empList, isPromotable);
    }
Exemplo n.º 15
0
        public Delegates2Example()
        {
            List <Employee> empList = new List <Employee>();

            empList.Add(new Employee()
            {
                ID = 101, Name = "Mary", Salary = 5000, Experience = 5
            });
            empList.Add(new Employee()
            {
                ID = 102, Name = "Mike", Salary = 4000, Experience = 4
            });
            empList.Add(new Employee()
            {
                ID = 103, Name = "John", Salary = 6000, Experience = 6
            });
            empList.Add(new Employee()
            {
                ID = 104, Name = "Todd", Salary = 3000, Experience = 3
            });

            Console.WriteLine("Like this:");
            Console.WriteLine("============================================");
            IsPromotable promotable = Promote;

            Employee.PromoteEmployee(empList, promotable);

            Console.WriteLine("\nOr with lambda expression:");
            Console.WriteLine("============================================");
            Employee.PromoteEmployee(empList, emp => emp.Experience >= 5);
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            List <Employee> emplist = new List <Employee>();

            emplist.Add(new Employee {
                Id = 101, Name = "Mark", Salary = 5000, Experience = 5
            });
            emplist.Add(new Employee {
                Id = 102, Name = "Mary", Salary = 6000, Experience = 4
            });
            emplist.Add(new Employee {
                Id = 103, Name = "John", Salary = 4000, Experience = 6
            });
            emplist.Add(new Employee {
                Id = 104, Name = "Todd", Salary = 7000, Experience = 3
            });

            IsPromotable isPromotable = new IsPromotable(Promote);

            Employee.PromoteEmployee(emplist, isPromotable);

            //Employee.PromoteEmployee(emplist, emp=>emp.Experience >= 5);  //using lamda experience

            Console.ReadKey();
        }
Exemplo n.º 17
0
        static void Main()
        {
            List <DelEmployee> employees = new List <DelEmployee>
            {
                new DelEmployee()
                {
                    Id = 1, Name = "Bea", Experience = 6, Salary = 5000
                },
                new DelEmployee()
                {
                    Id = 1, Name = "Rob", Experience = 3, Salary = 2000
                },
                new DelEmployee()
                {
                    Id = 1, Name = "Mike", Experience = 7, Salary = 6000
                },
                new DelEmployee()
                {
                    Id = 1, Name = "Sul", Experience = 4, Salary = 4000
                }
            };
            IsPromotable isPromotable = new IsPromotable(Promote);

            //DelEmployee.PromoteEmployee(employees,isPromotable);
            DelEmployee.PromoteEmployee(employees, emp => emp.Experience >= 5);
            Console.ReadLine();
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            List <Student> students = new List <Student>();

            students.Add(new Student()
            {
                Id = 1, Name = "John", Grade = 7, Credits = 5
            });
            students.Add(new Student()
            {
                Id = 2, Name = "Jelly", Grade = 9, Credits = 45
            });
            students.Add(new Student()
            {
                Id = 3, Name = "Jannie", Grade = 7, Credits = 25
            });
            students.Add(new Student()
            {
                Id = 4, Name = "Jolly", Grade = 8, Credits = 15
            });



            IsPromotable delegatePromotable = new IsPromotable(Condition);

            Student.PromoteStudent(students, delegatePromotable);

            // CAN BE REDUCED INTO 1 LINE USING LAMPDA
            //Student.PromoteStudent(students, s=>s.Grade > 8);

            Console.ReadKey();
        }
        static void main()
        {
            List <EmployeeD> empList = new List <EmployeeD>();

            empList.Add(new EmployeeD()
            {
                ID = 101, Name = "Adi", Salary = 20000, Experience = 2
            });
            empList.Add(new EmployeeD()
            {
                ID = 102, Name = "Fasil", Salary = 25000, Experience = 5
            });
            empList.Add(new EmployeeD()
            {
                ID = 103, Name = "Jishnu", Salary = 10000, Experience = 2
            });
            empList.Add(new EmployeeD()
            {
                ID = 104, Name = "Ashraf", Salary = 20000, Experience = 6
            });

            //instance of the delegate
            IsPromotable isPromotable = new IsPromotable(Promote);

            //calling the function
            EmployeeD.PromoteEmployee(empList, isPromotable);
        }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            List <Employee> emp = new List <Employee>();

            emp.Add(new Employee()
            {
                ID = 101, Name = "Zahid", Salary = 100000, Age = 18, Experience = 33
            });
            emp.Add(new Employee()
            {
                ID = 102, Name = "Alamin", Salary = 10000, Age = 28, Experience = 4
            });
            emp.Add(new Employee()
            {
                ID = 103, Name = "Asif", Salary = 100000, Age = 38, Experience = 5
            });
            emp.Add(new Employee()
            {
                ID = 104, Name = "Ahmed", Salary = 15000, Age = 48, Experience = 5
            });
            emp.Add(new Employee()
            {
                ID = 105, Name = "Mohaimen", Salary = 31000, Age = 180, Experience = 30
            });

            IsPromotable p = new IsPromotable(Promote);

            Employee.Promoteemployee(emp, p);



            Console.ReadKey();
        }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            List <Employee> list = new List <Employee>();

            list.Add(new Employee()
            {
                Id = 01, name = "ansh", salary = 19000, experience = 7
            });
            list.Add(new Employee()
            {
                Id = 02, name = "shoen", salary = 91000, experience = 4
            });
            list.Add(new Employee()
            {
                Id = 03, name = "jorden", salary = 29000, experience = 2
            });
            list.Add(new Employee()
            {
                Id = 04, name = "oliver", salary = 15000, experience = 8
            });

            Employee     emp          = new Employee();
            IsPromotable isPromotable = new IsPromotable(Promote);

            emp.promoteEmployee(list, isPromotable);
            Console.Read();
        }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            List <Employee> employeeDb = new List <Employee>();

            employeeDb.Add(new Employee()
            {
                Id = 101, Name = "Bob", Experience = 4, Salary = 6000
            });
            employeeDb.Add(new Employee()
            {
                Id = 102, Name = "Jill", Experience = 7, Salary = 12000
            });
            employeeDb.Add(new Employee()
            {
                Id = 103, Name = "Greg", Experience = 2, Salary = 1500
            });
            employeeDb.Add(new Employee()
            {
                Id = 104, Name = "Mark", Experience = 8, Salary = 10000
            });

            IsPromotable isPromotable = new IsPromotable(Promote);

            Employee.PromoteEmployees(employeeDb, isPromotable);

            Employee.PromoteEmployees(employeeDb, emp => emp.Experience > 5);

            //Employee.PromoteEmployees(employeeDb);

            Console.ReadLine();
        }
Exemplo n.º 23
0
        public static void Main(string[] args)
        {
            List <Employee> emplist = new List <Employee>();

            emplist.Add(new Employee()
            {
                ID = 101, Name = "Mary", Salary = 5000, Experience = 5
            });
            emplist.Add(new Employee()
            {
                ID = 111, Name = "Money", Salary = 4000, Experience = 2
            });
            emplist.Add(new Employee()
            {
                ID = 121, Name = "Mike", Salary = 6000, Experience = 4
            });
            emplist.Add(new Employee()
            {
                ID = 131, Name = "John", Salary = 2000, Experience = 6
            });
            emplist.Add(new Employee()
            {
                ID = 141, Name = "Todd", Salary = 3000, Experience = 3
            });

            IsPromotable isPromotable = new IsPromotable(Promote);

            Employee.PromoteEmployee(emplist, isPromotable);
        }
Exemplo n.º 24
0
        public static void Main(string[] args)
        {
            //A delegate is a type safe function pointer
            List <Employee> empList = new List <Employee>();

            empList.Add(new Employee()
            {
                ID = 101, Name = "Mary", Salary = 5000, Experience = 5
            });
            empList.Add(new Employee()
            {
                ID = 102, Name = "Mike", Salary = 4000, Experience = 4
            });
            empList.Add(new Employee()
            {
                ID = 103, Name = "John", Salary = 6000, Experience = 6
            });
            empList.Add(new Employee()
            {
                ID = 104, Name = "Todd", Salary = 3000, Experience = 3
            });

            IsPromotable promotable = new IsPromotable(Promote);

            Employee.PromoteEmployee(empList, promotable);
            Console.WriteLine("With Lambda");
            Employee.PromoteEmployee(empList, emp => emp.Salary < 5000);
        }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            List <Employee> emplist = new List <Employee>();

            emplist.Add(new Employee()
            {
                ID = 101, Name = "Purvin", Salary = 5000, Experience = 5
            });
            emplist.Add(new Employee()
            {
                ID = 102, Name = "Purvin1", Salary = 4000, Experience = 4
            });
            emplist.Add(new Employee()
            {
                ID = 103, Name = "Purvin2", Salary = 6000, Experience = 6
            });
            emplist.Add(new Employee()
            {
                ID = 104, Name = "Purvin3", Salary = 3000, Experience = 3
            });
            IsPromotable isPromotable = new IsPromotable(Promote);

            Employee.PromoteEmployee(emplist, isPromotable);
            Console.ReadLine();
        }
Exemplo n.º 26
0
    public static void Main()
    {
        List <Employee> empList = new List <Employee>();

        empList.Add(new Employee()
        {
            ID = 101, Name = "Mary", Salary = 5000, Experience = 5
        });
        empList.Add(new Employee()
        {
            ID = 101, Name = "Mike", Salary = 4000, Experience = 4
        });
        empList.Add(new Employee()
        {
            ID = 101, Name = "John", Salary = 6000, Experience = 6
        });
        empList.Add(new Employee()
        {
            ID = 101, Name = "Todd", Salary = 3000, Experience = 3
        });

        IsPromotable isPromotable = new IsPromotable(Promote);

        Employee.PromoteEmployee(empList, isPromotable);

        //	Lambda expression	//	behind the scene is the same, using delegate
        Employee.PromoteEmployee(empList, emp => emp.Experience >= 5);
    }
Exemplo n.º 27
0
        //public static void DisplayZero()
        //{
        //    for (int i = 0; i < 5000; i++)
        //    {
        //        Console.Write("0");
        //    }
        //}


        //public static void DisplayOne()
        //{
        //    for (int i = 0; i < 5000; i++)
        //    {
        //        Console.Write("1");
        //    }
        //}

        //public delegate void PrintDetails(string Details);



        //public static void Hello(string strMsg)
        //{
        //    Console.Write(strMsg);

        //}


        public static void Main()
        {
            //string time = "09:01:00 AM";

            //DateTime  xxxx = DateTime.ParseExact(time, "HH:mm:ss tt", System.Globalization.CultureInfo.CurrentCulture);

            //DateTime d = new DateTime();
            //d.AddHours(xxxx.Hour);


            //var timespan = new TimeSpan(3, 0, 0);
            //var output = new DateTime().Add(timespan).ToString("hh:mm tt");


            string   s = "5:19:41 PM";
            DateTime t = DateTime.ParseExact(s, "h:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
            //if you really need a TimeSpan this will get the time elapsed since midnight:
            int y = t.Hour;



            IsPromotable IsPromotable = new IsPromotable(Promote);

            Person.PromotePerson(GenerateListOfPerson(), IsPromotable);



            //PrintDetails xx = new PrintDetails(Hello);
            //xx("Hello Vincent");


            var list = GenerateListOfPerson();
            var City = from x in list
                       group x by x.address into g
                       where g.FirstOrDefault().age <= 31
                       select new { g.FirstOrDefault().Name, g.FirstOrDefault().address };

            City.ToList().ForEach(m => Console.WriteLine(m.Name.ToString() + "" + m.address.ToString()));



            //Console.ReadLine();

            //Thread thZero = new Thread(DisplayZero);
            //Thread thOne = new Thread(DisplayOne);
            //thZero.Priority = ThreadPriority.Highest;
            //thOne.Priority = ThreadPriority.Lowest;

            //thZero.Start();
            //thOne.Start();

            //thZero.Join();
            //thOne.Join();


            //MessageBox.Show("Done");

            //Console.ReadLine();
        }
Exemplo n.º 28
0
 public static void PromoteEmployee(List<Employee> emplist, IsPromotable EmptoPromote)
 {
     foreach (Employee emp in emplist)
     {
         if (EmptoPromote(emp))
         {
             Console.WriteLine(emp.Name + "is Promoted");
         }
     }
 }
Exemplo n.º 29
0
 public static void PromoteEmployee(List<Employee> employeelist,IsPromotable IsEligibleToPromote)
 {
     foreach (Employee employee in employeelist)
     {
         if (IsEligibleToPromote(employee))
         {
             Console.WriteLine(employee.Name + " promoted ");
         }
     }
 }
Exemplo n.º 30
0
 public static void PromoteEmployee(List<Employee> employees, IsPromotable isEligiblePromote)
 {
     foreach (var employee in employees)
     {
         if (isEligiblePromote(employee))
         {
             Console.WriteLine(employee.Name + " promoted");
         }
     }
 }
Exemplo n.º 31
0
 public static void PromoteEmployee(List <Employee> employees, IsPromotable isEligibleToPromote)
 {
     foreach (Employee emp in employees)
     {
         if (isEligibleToPromote(emp))
         {
             Console.WriteLine(emp.EmpName + " promoted");
         }
     }
 }
Exemplo n.º 32
0
 public static void PromoteEmployee(List <Employee> employeeList, IsPromotable IsEligibleToPromote)
 {
     foreach (Employee employee in employeeList)
     {
         if (IsEligibleToPromote(employee))
         {
             Console.WriteLine(employee.Name + " promoted");
         }
     }
 }
Exemplo n.º 33
0
 public static void PreviewDriver(List <Employee> employees, IsPromotable isEligibleToPromote)
 {
     foreach (Employee emp in employees)
     {
         if (!isEligibleToPromote(emp))
         {
             Console.WriteLine(emp.EmpName + " under review");
         }
     }
 }
Exemplo n.º 34
0
 public static void getPromoted(List<Employee> employeeList, IsPromotable IsEligibleToPromote)
 {
     foreach (Employee emp in employeeList)
     {
         if (IsEligibleToPromote(emp))
         {
             Console.WriteLine(emp.name + " has got promoted");
         }
     }
 }
Exemplo n.º 35
0
 public static void PromoteEmployee(List <Employee> employeeList, IsPromotable IsEligibleToPromote)
 {
     foreach (Employee employee in employeeList)
     {
         if (IsEligibleToPromote(employee))
         {
             Console.WriteLine($"{employee.name} = {employee.salary}");
         }
     }
 }
Exemplo n.º 36
0
 public void PromotedEmployee(List <Employee> employees, IsPromotable promotableEmployee)
 {
     foreach (var data in employees)
     {
         if (promotableEmployee(data))
         {
             Console.WriteLine(data.Name + " Promoted");
         }
     }
 }
 public static void PromoteEmployee(List<Employee> emploList,IsPromotable isPromotable)
 {
     foreach (Employee employee in emploList )
         {
             if (isPromotable(employee))
             {
                 Console.WriteLine("{0} is promoted", employee.name);
             }
         }
 }
Exemplo n.º 38
0
 public static void PromoteEmployee(List <Employee> employeeList, IsPromotable isEligible)
 {
     foreach (Employee employee in employeeList)
     {
         if (isEligible(employee))
         {
             Console.WriteLine("congrats " + employee.Name + " You are promoted");
         }
     }
 }
Exemplo n.º 39
0
 public static void PromoteEmp(List <Emp> empList, IsPromotable isPromotable)
 {
     foreach (Emp e in empList)
     {
         if (isPromotable(e))
         {
             Console.WriteLine(e.Name + " is Promoted \n");
         }
     }
 }
Exemplo n.º 40
0
 public static void PromoteEmployee(List <EmployeeDelegateTest> employee, IsPromotable IsEligibleForPromotion)
 {
     foreach (EmployeeDelegateTest emp in employee)
     {
         if (IsEligibleForPromotion(emp))
         {
             Console.WriteLine($"{emp.Name} is promoted");
         }
     }
 }
Exemplo n.º 41
0
 public void PromoteEmployee(List<Employee> listOfEmployees, IsPromotable promotable)
 {
     foreach(Employee e in listOfEmployees)
     {
         if (promotable(e))
         {
             Console.WriteLine("ID: {0} with name: {1} is promotable", e.id, e.name);
         }
     }
     Console.Read();
 }
Exemplo n.º 42
0
 public static void PromoteEmployee(List<Employee> empList, IsPromotable isEligibleToPromote)
 {
     foreach (Employee emp in empList)
     {
         // We have removed hard coded logic from here. By using delegate.
         if (isEligibleToPromote(emp))
         {
             Console.WriteLine(emp.Name + " - Promoted");
         }
     }
 }
Exemplo n.º 43
0
 static void Main(string[] args)
 {
     List<Employee> emplist = new List<Employee>();
     emplist.Add(new Employee() { ID = 1, Name = "SOWMYA", Salary = 5000, exp = 5 });
     emplist.Add(new Employee() { ID = 1, Name = "MUKUND", Salary = 6000, exp = 6 });
     IsPromotable ispromotable = new IsPromotable(Promote);
     Employee.PromoteEmployee(emplist,ispromotable);
     //foreach (Employee emp in emplist)
     //{
     //    ispromotable(emp);
     //}
 }
        static void Main(string[] args)
        {
            List<Employee> empList = new List<Employee>();
            empList.Add(new Employee { id = 101, name = "Ujjwal", salary = 50000, experience = 1 });
            empList.Add(new Employee { id = 102, name = "Swati", salary = 60000, experience = 2 });
            empList.Add(new Employee { id = 103, name = "Niki", salary = 50000, experience = 3 });
            empList.Add(new Employee { id = 104, name = "Bharti", salary = 60000, experience = 4 });

            IsPromotable isHe = new IsPromotable(Promote);
            Employee.PromoteEmployee(empList,isHe);

            Console.ReadKey();
        }