static void Main(string[] args) { JobList jobs = new JobList(); List <Employee> employees = new List <Employee>(); string command; while ((command = Console.ReadLine()) != "End") { var tokens = command.Split(); switch (tokens[0]) { case "Job": Employee employee = employees.First(e => e.Name == tokens[3]); jobs.AddJob(new Job(tokens[1], int.Parse(tokens[2]), employee)); break; case "StandardEmployee": employees.Add(new StandardEmployee(tokens[1])); break; case "PartTimeEmployee": employees.Add(new PartTimeEmployee(tokens[1])); break; case "Pass": jobs.ToList().ForEach(j => j.Update()); break; case "Status": jobs.ForEach(Console.WriteLine); break; } } }
public string DebugString() { var sb = new StringBuilder($"{Name}: {JobCount()} jobs, {MachineCount()} machines"); sb.Append("\nMachines:"); MachineList.ForEach(m => sb.Append($" {m.Name}")); sb.Append("\nJobs:"); JobList.ForEach(j => sb.Append($"\n{j.DebugString()}")); return(sb.ToString()); }
private static void Main(string[] args) { IList <IEmployee> employees = new List <IEmployee>(); JobList jobs = new JobList(); string command = string.Empty; while ((command = Console.ReadLine()) != "End") { string[] tokens = command.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); IEmployee emp = null; switch (tokens[0]) { case "Job": emp = employees.First(e => e.Name == tokens[3]); Job job = new Job(tokens[1], int.Parse(tokens[2]), emp); job.JobDone += jobs.HandleJobCompletion; jobs.Add(job); break; case "StandartEmployee": emp = new StandartEmployee(tokens[1]); employees.Add(emp); break; case "PartTimeEmployee": emp = new PartTimeEmployee(tokens[1]); employees.Add(emp); break; case "Pass": List <Job> dummyJobs = new List <Job>(jobs); foreach (var j in dummyJobs) { j.Update(); } break; case "Status": jobs.ForEach(j => Console.WriteLine(j)); break; default: break; } } }
static void Main(string[] args) { var jobs = new JobList(); var employees = new List <IEmployee>(); string input; while ((input = Console.ReadLine()) != "End") { var tokens = input.Split(); var command = tokens[0]; switch (command) { case "Job": var employee = employees.FirstOrDefault(a => a.Name == tokens[3]); var newJob = new Job(tokens[1], int.Parse(tokens[2]), employee); jobs.AddJob(newJob); break; case "StandardEmployee": employees.Add(new StandardEmployee(tokens[1])); break; case "PartTimeEmployee": employees.Add(new PartTimeEmployee(tokens[1])); break; case "Pass": foreach (var job in jobs.ToList()) { job.Update(); } break; case "Status": jobs.ForEach(Console.WriteLine); break; } } }