Пример #1
0
        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);
                }
            }
        }
Пример #2
0
        public 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;
                }
            }
        }