Ejemplo n.º 1
0
        public static void Exist(Firm firm)
        {
            string name = "", surname = "";

            Console.WriteLine("Input employee data.");
            Console.Write("Input name: ");
            name = Console.ReadLine();
            Console.Write("Input surname: ");
            surname = Console.ReadLine();

            var emp = new Employee {
                Name = name, Surname = surname
            };

            if (firm.CheckEmployee(emp))
            {
                Console.WriteLine($"Such employee {name} {surname} is in firm.");
            }
            else
            {
                Console.WriteLine($"There are no such employee {name} {surname} in firm.");
            }
        }
Ejemplo n.º 2
0
        public static void Start()
        {
            Console.WriteLine("Hellow, welcome to my project.\nYou have a firm, with list of employees.\nTo work with list use commands.\n");
            Console.WriteLine("Commands: \n.help\n.add\n.remove\n.work\n.task\n.check\n.exist\n.show\n.count\n.exit\n");
            string command = "";
            bool   check   = true;

            Firm            firm      = new Firm();
            List <Employee> employees = new List <Employee>()
            {
                new Employee {
                    Name = "Employee", Surname = "SurEmployee", Experience = "ExE"
                },
                new Worker {
                    Name = "Worker", Surname = "SurWorker", Experience = "ExW"
                },
                new Manager {
                    Name = "Manager", Surname = "SurManager", Experience = "ExM"
                },
                new Foreman {
                    Name = "Foreman", Surname = "SurForeman", Experience = "ExF"
                }
            };

            firm.Employees = employees;
            GenericClass <Employee> generics = new GenericClass <Employee>();

            do
            {
                command = Console.ReadLine();
                switch (command)
                {
                case ".help":
                    Help();
                    Console.WriteLine();
                    break;

                case ".add":
                    Add(firm);
                    Console.WriteLine();
                    break;

                case ".remove":
                    Remove(firm);
                    Console.WriteLine();
                    break;

                case ".work":
                    Work(firm);
                    Console.WriteLine();
                    break;

                case ".task":
                    GiveTasks(firm);
                    Console.WriteLine();
                    break;

                case ".check":
                    CheckWorkers(firm);
                    Console.WriteLine();
                    break;

                case ".exist":
                    Exist(firm);
                    Console.WriteLine();
                    break;

                case ".show":
                    firm.ShowAllEmployes();
                    Console.WriteLine();
                    break;

                case ".count":
                    Console.WriteLine($"This firm has {generics.Count(firm.Employees)} employees.");
                    Console.WriteLine();
                    break;

                case ".exit":
                    check = false;
                    Console.WriteLine();
                    break;

                default:
                    Console.WriteLine("Invalid input. Try again.");
                    Console.WriteLine();
                    break;
                }
            } while (check);

            Console.WriteLine("Press any button, to exit.");
            Console.ReadLine();
        }