//Create task static void CreateTask(IJiraTaskCreatable creator, string info) { creator.CreateTask(info); }
static void Main(string[] args) { int[] data = new int[] { 1, 2, 3, 4, 5 }; //for example, lets imagine that val in entered from keyboard int val = 0; //set delegate link to method MathOperation operation; if (val > 0) { operation = AddTwo; } else { operation = MultiplyTwo; } //call method that takes massive and delegate that has link to method data = DoSomeOperation(data, operation); AddTwo(data[2]); //using Node for List (send any type) MyList <int> listInt = new MyList <int>(); listInt.AddHead(1); listInt.AddHead(2); listInt.AddHead(3); int[] mas = new int[] { 1, 2, 3, 4, 5 }; //create employes massive with 3 employee objects Employee employee1 = new PMEmployee("firstName1", "lastName1", 1000, mas, "NoProject"); PMEmployee employee2 = new PMEmployee("firstName2", "lastName2", 1000, mas, "Wex"); DevEmployee employee3 = new DevEmployee("firstName3", "lastName3", 1000, mas, "Project"); QAEmployee qaemployee = new QAEmployee("QaName", "QaSurname", 1500f, mas, "WEB"); VacuumCleaner cleaner = new VacuumCleaner("Samsung"); LeadQAEmployee leadqaemployee = new LeadQAEmployee("QaName", "QaSurname", 1500f, mas, "Lead"); //Massive IWorkable type (interface) IWorkable[] employesMas = new IWorkable[] { employee1, employee2, employee3, qaemployee, cleaner, leadqaemployee }; //Use static method and counter for method calls DevEmployee.GetClassInfo(); DevEmployee.GetClassInfo(); DevEmployee.GetClassInfo(); Console.WriteLine("Count of GetClassInfo method calls is {0} )", DevEmployee.NumberOfCalls); Console.WriteLine(" "); //Use static method without initialization class object int res = mas.Sum(); Console.WriteLine("Sum of mas ellements is {0} ", res); Console.WriteLine(" "); string masRes = mas.MasToString(); Console.WriteLine("Massive {0} ", masRes); Console.WriteLine(" "); //Simple list IWorkable type (interface) List <IWorkable> employesList = new List <IWorkable>(); employesList.Add(employee1); employesList.Add(employee2); employesList.Add(employee3); employesList.Add(qaemployee); employesList.Add(cleaner); employesList.Add(leadqaemployee); Console.WriteLine("Massive of exact employee is "); Console.WriteLine(employee1.PrintMassive(mas)); Console.WriteLine(" "); //initialize employees cleaner.Producer = "Xiaomi"; //Work with massive element, using indexator Console.WriteLine("Exact element of exact employee {0}", employee1.Marks[4]); Console.WriteLine(" "); foreach (IWorkable employee in employesMas) { Console.WriteLine(employee.GetInfo()); } Console.WriteLine(" "); foreach (IWorkable worker in employesList) { if (worker is IJiraTaskCreatable) { IJiraTaskCreatable taskCreator = (IJiraTaskCreatable)worker; //CreateTask(taskCreator, "info"); taskCreator.CreateTask("Task1"); //(worker as IJiraTaskCreatable).CreateTask("Task1"); } if (worker is PMEmployee) { PMEmployee pm = (PMEmployee)worker; Console.WriteLine(pm.ManagingProject); Console.ReadKey(); } } }
static void Main(string[] args) { Employee employee1 = new PMEmployee("em1", "em1", 1200f, "NoProject"); //for (int i = 0; i <employee1.Marks.Length; i++) //{ // Console.WriteLine(employee1.Marks[i]); //} for (int i = 0; i < 5; i++) { Console.WriteLine(employee1[i]); } PMEmployee employee2 = new PMEmployee("pm2", "pm2", 4200f, "Wex"); DevEmployee employee3 = new DevEmployee("dv3", "dv3", 1800f, "C#"); QAEmployee employee4 = new QAEmployee("qa1", "qa1", 2500f, "Web"); QAEmployee employee5 = new QAEmployee("qa2", "qa2", 2500f, "Desktop"); LeadQAEmployee leadQAEmployee = new LeadQAEmployee("qalead3", "qalead", 2600f, "Team"); VacuumCleaner cleaner = new VacuumCleaner("Samsung"); /*IWorkable[] employees = new IWorkable[] { * employee1, * employee2, * employee3, * employee4, * employee5, * cleaner, * leadQAEmployee };*/ List <IWorkable> employees = new List <IWorkable>(); employees.Add(employee1); employees.Add(employee2); employees.Add(employee3); employees.Add(employee4); employees.Add(employee5); employees.Add(cleaner); employees.Add(leadQAEmployee); foreach (IWorkable worker in employees) { if (worker is IJiraTaskCreatable) { IJiraTaskCreatable taskCreator = (IJiraTaskCreatable)worker; taskCreator.CreateTask("Task 1"); } if (worker is PMEmployee) { PMEmployee pm = (PMEmployee)worker; Console.WriteLine(pm.ManagingProject); } } }