public static void Main() { JobsList jobs = new JobsList(); IList <IEmployee> employees = new List <IEmployee>(); string[] input = Console.ReadLine().Split(); while (!input[0].Equals("End")) { switch (input[0]) { case "Job": Job currentJob = new Job(input[1], int.Parse(input[2]), employees.FirstOrDefault(e => e.Name.Equals(input[3]))); jobs.Add(currentJob); currentJob.JobDone += jobs.OnJobDone; break; case "StandartEmployee": StandartEmployee standartEmployee = new StandartEmployee(input[1]); employees.Add(standartEmployee); break; case "PartTimeEmployee": PartTimeEmployee parttimeEmployee = new PartTimeEmployee(input[1]); employees.Add(parttimeEmployee); break; case "Pass": foreach (Job job in jobs.ToArray()) { job.Update(); } break; case "Status": foreach (Job job in jobs) { Console.WriteLine(job); } break; } input = Console.ReadLine().Split(); } }
static void Main(string[] args) { List <IJob> jobs = new List <IJob>(); List <IEmployee> employees = new List <IEmployee>(); string input; while ((input = Console.ReadLine()) != "End") { string[] tokens = input.Split(); switch (tokens[0]) { case "StandardEmployee": IEmployee employee = new StandardEmployee(tokens[1]); employees.Add(employee); break; case "PartTimeEmployee": employee = new PartTimeEmployee(tokens[1]); employees.Add(employee); break; case "Job": var empl = employees.First(e => e.Name == tokens[3]); Job job = new Job(tokens[1], int.Parse(tokens[2]), empl); jobs.Add(job); break; case "Pass": jobs.Where(j => !j.IsDone).ToList().ForEach(j => j.Update()); break; case "Status": jobs.ForEach(j => Console.WriteLine(j.ToString())); break; } } }
public static void Main() { JobList jobs = new JobList(); List <Employee> employees = new List <Employee>(); while (true) { string[] input = Console.ReadLine().Split(); if (input[0] == "End") { break; } else if (input[0] == "Job") { Employee employee = employees.Find(e => e.Name == input[3]); jobs.AddJob(new Job(employee, int.Parse(input[2]), input[1])); } else if (input[0] == "StandardEmployee") { StandardEmployee employee = new StandardEmployee(input[1]); employees.Add(employee); } else if (input[0] == "PartTimeEmployee") { PartTimeEmployee employee = new PartTimeEmployee(input[1]); employees.Add(employee); } else if (input[0] == "Pass") { jobs.ToList().ForEach(j => j.Update()); } else if (input[0] == "Status") { jobs.ForEach(Console.WriteLine); } } }