Exemplo n.º 1
0
        // Create a method that allows external code to add an employee
        public void AddEmployee()
        {
            Console.WriteLine("Enter Employee's First Name");
            var firstName = Console.ReadLine();

            Console.WriteLine("Enter Employee's Last Name");
            var lastName = Console.ReadLine();

            Console.WriteLine("Enter Employee's Age");
            var  age  = Convert.ToInt32(Console.ReadLine());
            bool menu = true;

            while (menu)
            {
                Console.WriteLine("New Employee Position...");
                Console.WriteLine("1. Boss");
                Console.WriteLine("2. Supervisor");
                Console.WriteLine("3. Manager");
                Console.WriteLine("4. Clerk");
                var      empPos   = Convert.ToInt32(Console.ReadLine());
                var      fullName = $"{firstName} {lastName}";
                Employee empToAdd;

                switch (empPos)
                {
                case 1:
                    empToAdd = new Boss(fullName, age);
                    EmployeeList.Add(empToAdd);
                    Console.WriteLine($"{empToAdd.Name} the {empToAdd.GetType().Name} was added to {Name} Employee list");
                    menu = false;
                    break;

                case 2:
                    empToAdd = new Supervisor(fullName, age);
                    EmployeeList.Add(empToAdd);
                    Console.WriteLine($"{empToAdd.Name} the {empToAdd.GetType().Name} was added to {Name} Employee list");
                    menu = false;
                    break;

                case 3:
                    empToAdd = new Manager(fullName, age);
                    EmployeeList.Add(empToAdd);
                    Console.WriteLine($"{empToAdd.Name} the {empToAdd.GetType().Name} was added to {Name} Employee list");
                    menu = false;
                    break;

                case 4:
                    empToAdd = new Clerk(fullName, age);
                    EmployeeList.Add(empToAdd);
                    Console.WriteLine($"{empToAdd.Name} the {empToAdd.GetType().Name} was added to {Name} Employee list");
                    menu = false;
                    break;

                default:
                    Console.WriteLine("Please Enter 1-3");
                    break;
                }
            }
        }