Пример #1
0
    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;
            }
        }
    }
Пример #2
0
        public static void Main()
        {
            var jobs      = new JobList();
            var employees = new List <Employee>();

            while (true)
            {
                var    input   = Console.ReadLine().Split();
                string command = input[0];

                switch (command)
                {
                case "Job":
                    string jobName       = input[1];
                    int    requiredHours = int.Parse(input[2]);
                    string employeeName  = input[3];
                    var    employee      = employees.First(e => e.Name == employeeName);
                    var    job           = new Job(jobName, requiredHours, employee);
                    jobs.AddJob(job);
                    break;

                case "StandardEmployee":
                    employeeName = input[1];
                    employee     = new StandardEmployee(employeeName);
                    employees.Add(employee);
                    break;

                case "PartTimeEmployee":
                    employeeName = input[1];
                    employee     = new PartTimeEmployee(employeeName);
                    employees.Add(employee);
                    break;

                case "Pass":
                    jobs.ToList().ForEach(j => j.Update());

                    break;

                case "Status":
                    foreach (var currentJob in jobs)
                    {
                        Console.WriteLine(currentJob);
                    }

                    break;

                case "End":
                    return;
                }
            }
        }
    static void Main()
    {
        List <Employee> employees = new List <Employee>();
        JobList         jobs      = new JobList();

        string input = Console.ReadLine();

        while (input != "End")
        {
            string[] commandTokens = input.Split(' ', StringSplitOptions.RemoveEmptyEntries);

            Job      job      = null;
            Employee employee = null;

            switch (commandTokens[0])
            {
            case "Job":
                string jobName       = commandTokens[1];
                int    hoursRequired = int.Parse(commandTokens[2]);
                employee = employees.First(e => e.Name == commandTokens[3]);
                job      = new Job(jobName, hoursRequired, employee);
                jobs.AddJob(job);
                break;

            case "StandardEmployee":
                employee = new StandartEmployee(commandTokens[1]);
                employees.Add(employee);
                break;

            case "PartTimeEmployee":
                employee = new PartTimeEmployee(commandTokens[1]);
                employees.Add(employee);
                break;

            case "Pass":
                Pass(jobs);
                break;

            case "Status":
                Status(jobs);
                break;
            }

            input = Console.ReadLine();
        }
    }
Пример #4
0
        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;
                }
            }
        }