Example #1
0
        static void Main(string[] args)
        {
            Company company = new Company();

            //Prepared employees list
            {
                HourlyEmployee hourlyEmployee = new HourlyEmployee("Bob", 30, "Male", Employee.Position.HourlyEmployee, 8, 5);
                company.AddEmployee(hourlyEmployee, 0);

                hourlyEmployee = new HourlyEmployee("John", 27, "Male", Employee.Position.HourlyEmployee, 8, 5);
                company.AddEmployee(hourlyEmployee, 0);

                hourlyEmployee = new HourlyEmployee("Gyda", 22, "Female", Employee.Position.HourlyEmployee, 8, 5);
                company.AddEmployee(hourlyEmployee, 0);

                /////////////////////////////////////////////////////////////////
                SalariedEmployee salariedEmployee = new SalariedEmployee("Arthur", 35, "Male", Employee.Position.SalariedEmployee, 15, 5);
                company.AddEmployee(salariedEmployee, 0);

                salariedEmployee = new SalariedEmployee("Cathy", 37, "Female", Employee.Position.SalariedEmployee, 15, 5);
                company.AddEmployee(salariedEmployee, 0);

                salariedEmployee = new SalariedEmployee("Isabella", 37, "Female", Employee.Position.SalariedEmployee, 15, 5);
                company.AddEmployee(salariedEmployee, 0);

                /////////////////////////////////////////////////////////////////
                Manager manager = new Manager("Michael", 40, "Male", Employee.Position.Manager, 75, 1500);
                company.AddEmployee(manager, 0);

                manager = new Manager("Alex", 41, "Male", Employee.Position.Manager, 75, 1500);
                company.AddEmployee(manager, 0);

                /////////////////////////////////////////////////////////////////
                Executive executive = new Executive("Thomas", 47, "Male", Employee.Position.Executive, 250);
                company.AddEmployee(executive, 0);
            }

            //Prepared unemployed persons list
            {
                HourlyEmployee hourlyEmployee = new HourlyEmployee("Tom", 20, "Male");
                company.RemoveEmployee(hourlyEmployee, 0);

                hourlyEmployee = new HourlyEmployee("Mike", 22, "Male");
                company.RemoveEmployee(hourlyEmployee, 0);
            }

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Welcome to the company manager!!!");
            Console.ResetColor();

            do
            {
                Menu();
                MenuPoint choice = InputMenu();

                if (choice == MenuPoint.Exit)
                {
                    Console.WriteLine("Close the program...");
                    Console.ReadKey();
                    break;
                }

                switch (choice)
                {
                case MenuPoint.ShowEmployees:
                {
                    company.ShowEmployees();
                    break;
                }

                case MenuPoint.ShowUnemployedPersons:
                {
                    company.ShowUnemployedPersons();
                    break;
                }

                case MenuPoint.HireEmployee:
                {
                    company.HireEmmployee();
                    break;
                }

                case MenuPoint.DismissEmployee:
                {
                    company.DismissEmployee();
                    break;
                }

                case MenuPoint.PromoteEmployee:
                {
                    company.PromoteEmployee();
                    break;
                }

                default:
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Unknown command!");
                    Console.ResetColor();
                    break;
                }
                }

                Console.WriteLine("Input any key to continue...");
                Console.ReadKey();
                Console.Clear();
            } while (true);
        }
Example #2
0
        static HourlyEmployee CastToHourlyEmployee(Employee employee)
        {
            HourlyEmployee hourlyEmployee = new HourlyEmployee(employee._name, employee._age, employee._gender, Employee.Position.HourlyEmployee, 8, 5);

            return(hourlyEmployee);
        }
Example #3
0
        static SalariedEmployee CastToSalariedEmployee(HourlyEmployee hourlyEmployee)
        {
            SalariedEmployee salariedEmployee = new SalariedEmployee(hourlyEmployee._name, hourlyEmployee._age, hourlyEmployee._gender, Employee.Position.SalariedEmployee, 5, 15);

            return(salariedEmployee);
        }
Example #4
0
        static void Main(string[] args)
        {
            //remove localization
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("US");

            //set background and Foreground color
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.Clear();

            int counter = 0;

            var employee1 = new Executive();

            employee1.Name           = "Makarova Tatsiana";
            employee1.Id             = ++counter;
            employee1.numberOfShares = 4000000;
            employee1.incomePerShare = 100;
            employee1.Salary         = employee1.Payment;

            var employee2 = new Manager();

            employee2.Name            = "Dzianis Shastak";
            employee2.Id              = ++counter;
            employee2.kpi             = true;
            employee2.constantPayment = 8000;
            employee2.variablPayment  = 16000;
            employee2.Salary          = employee2.Payment;

            var employee3 = new Manager();

            employee3.Name            = "Maria Makarova";
            employee3.Id              = ++counter;
            employee3.kpi             = false;
            employee3.constantPayment = 8000;
            employee3.variablPayment  = 16000;
            employee3.Salary          = employee3.Payment;

            var employee4 = new SalariedEmployee();

            employee4.Name    = "Orlova Evgeniya";
            employee4.Id      = ++counter;
            employee4.payment = 15000;
            employee4.Salary  = employee4.payment;

            var employee5 = new HourlyEmployee();

            employee5.Name                = "Dmitry Yankov";
            employee5.Id                  = ++counter;
            employee5.paymentPerHour      = 200;
            employee5.numberOfWorkedHours = 40;
            employee5.Salary              = employee5.Payment;

            List <Employee> listOfAllEmployees = new List <Employee>()
            {
                employee1, employee2, employee3, employee4, employee5
            };

            bool repeatMenu = true;

            while (repeatMenu)
            {
                repeatMenu = false;

                FirstMessage();

                ShowEmployees(listOfAllEmployees);

                ActingMenu();

                var userChoseAction = Console.ReadLine();

                switch (userChoseAction)
                {
                //Hire a new employee
                case "1":

                    Console.Clear();

                    Console.WriteLine("\n\tPlease select position of new employee:");
                    Console.WriteLine("\n\t1.Hourly Employee");
                    Console.WriteLine("\t2.Salaries Employee");
                    Console.WriteLine("\t3.Manager Employee");
                    Console.WriteLine("\t4.Executive Employee");

                    var newEmployeePosition = Console.ReadLine();

                    switch (newEmployeePosition)
                    {
                    //hourly
                    case "1":

                        var addNewHourlyEmployee = new HourlyEmployee();

                        Console.WriteLine("\tPlease type a name of new employee");

                        addNewHourlyEmployee.Name = Console.ReadLine();

                        addNewHourlyEmployee.Id = ++counter;

                        Console.WriteLine($"\tPlease enter a payment per hour for {addNewHourlyEmployee.Name}");

                        var paymentPerHourUserInput = Console.ReadLine();

                        addNewHourlyEmployee.paymentPerHour = ParsingForDouble(paymentPerHourUserInput);

                        Console.WriteLine($"\tPlease enter number of worked hours for {addNewHourlyEmployee.Name}");

                        var numberOfWorkedHoursUserInput = Console.ReadLine();

                        addNewHourlyEmployee.numberOfWorkedHours = ParsingForDouble(numberOfWorkedHoursUserInput);

                        addNewHourlyEmployee.Salary = addNewHourlyEmployee.Payment;

                        listOfAllEmployees.Add(addNewHourlyEmployee);

                        FirstMessage();

                        ShowEmployees(listOfAllEmployees);

                        ReturnToMainMenu();

                        Console.ReadKey();

                        Console.Clear();

                        repeatMenu = true;

                        break;

                    //salaried
                    case "2":

                        var addNewSalariedEmployee = new SalariedEmployee();

                        Console.WriteLine("\tPlease type a name of new employee");

                        addNewSalariedEmployee.Name = Console.ReadLine();

                        addNewSalariedEmployee.Id = ++counter;

                        Console.WriteLine($"\tPlease enter a salary for {addNewSalariedEmployee.Name}");

                        var salaryUserInput = Console.ReadLine();

                        addNewSalariedEmployee.payment = ParsingForDouble(salaryUserInput);

                        addNewSalariedEmployee.Salary = addNewSalariedEmployee.payment;

                        listOfAllEmployees.Add(addNewSalariedEmployee);

                        FirstMessage();

                        ShowEmployees(listOfAllEmployees);

                        ReturnToMainMenu();

                        Console.ReadKey();

                        Console.Clear();

                        repeatMenu = true;

                        break;

                    //manager
                    case "3":

                        var addNewManagerEmployee = new Manager();

                        Console.WriteLine("\tPlease type a name of new manager");

                        addNewManagerEmployee.Name = Console.ReadLine();

                        addNewManagerEmployee.Id = ++counter;

                        Console.WriteLine($"\tPlease enter a constant payment for {addNewManagerEmployee.Name}");

                        var constantPaymentUserInput = Console.ReadLine();

                        addNewManagerEmployee.constantPayment = ParsingForDouble(constantPaymentUserInput);

                        Console.WriteLine($"\tPlease enter a variabl payment for {addNewManagerEmployee.Name}");

                        var variablPaymentUserInput = Console.ReadLine();

                        addNewManagerEmployee.variablPayment = ParsingForDouble(variablPaymentUserInput);

                        addNewManagerEmployee.Salary = addNewManagerEmployee.Payment;

                        listOfAllEmployees.Add(addNewManagerEmployee);

                        FirstMessage();

                        ShowEmployees(listOfAllEmployees);

                        ReturnToMainMenu();

                        Console.ReadKey();

                        Console.Clear();

                        repeatMenu = true;

                        break;

                    //executer
                    case "4":

                        var addNewExecutiveEmployee = new Executive();

                        Console.WriteLine("\tPlease type a name of new employee");

                        addNewExecutiveEmployee.Name = Console.ReadLine();

                        addNewExecutiveEmployee.Id = ++counter;

                        Console.WriteLine($"\tPlease enter a number of shares for {addNewExecutiveEmployee.Name}");

                        var numberOfSharesUserInput = Console.ReadLine();

                        addNewExecutiveEmployee.numberOfShares = ParsingForDouble(numberOfSharesUserInput);

                        Console.WriteLine($"\tPlease enter income per shares for {addNewExecutiveEmployee.Name}");

                        var incomePerShareUserInput = Console.ReadLine();

                        addNewExecutiveEmployee.incomePerShare = ParsingForDouble(incomePerShareUserInput);

                        addNewExecutiveEmployee.Salary = addNewExecutiveEmployee.Payment;

                        listOfAllEmployees.Add(addNewExecutiveEmployee);

                        FirstMessage();

                        ShowEmployees(listOfAllEmployees);

                        ReturnToMainMenu();

                        Console.ReadKey();

                        Console.Clear();

                        repeatMenu = true;

                        break;

                    default:

                        Console.WriteLine("\n\tYou've entered unknown operation. \n\tPlease type any key and you will be redirected to the main menu");

                        Console.ReadKey();

                        Console.Clear();

                        repeatMenu = true;

                        break;
                    }

                    break;

                //Fire an employee
                case "2":

                    Console.WriteLine("Please type Id of employee you vant to fire");

                    var fireEmployee = Console.ReadLine();

                    int idForDel = parseId(fireEmployee, counter);

                    for (int i = 0; i <= listOfAllEmployees.Count; i++)
                    {
                        if (listOfAllEmployees[i].Id == idForDel)
                        {
                            listOfAllEmployees.RemoveAt(i);
                        }
                    }

                    FirstMessage();

                    ShowEmployees(listOfAllEmployees);

                    ReturnToMainMenu();

                    Console.ReadKey();

                    Console.Clear();

                    repeatMenu = true;

                    break;

                //Promote an employee
                case "3":

                    Console.WriteLine("Please type Id of employee you vant to promote");

                    var promoteEmployee = Console.ReadLine();

                    int idForPromote = parseId(promoteEmployee, counter);

                    string positionForPromote = null;

                    for (int i = 0; i <= listOfAllEmployees.Count; i++)
                    {
                        if (i == idForPromote)
                        {
                            positionForPromote = listOfAllEmployees[i - 1].typeOfsalary.ToString();
                        }
                    }

                    switch (positionForPromote)
                    {
                    case "Hourly":

                        var HourlyPromoteForSalary = new SalariedEmployee();

                        HourlyPromoteForSalary.Name = listOfAllEmployees[idForPromote - 1].Name;

                        HourlyPromoteForSalary.Id = listOfAllEmployees[idForPromote - 1].Id;

                        Console.WriteLine($"\tPlease enter a salary for {listOfAllEmployees[idForPromote - 1].Name}");

                        var salaryUserInput = Console.ReadLine();

                        HourlyPromoteForSalary.payment = ParsingForDouble(salaryUserInput);

                        HourlyPromoteForSalary.Salary = HourlyPromoteForSalary.payment;

                        listOfAllEmployees.RemoveAt(idForPromote - 1);

                        listOfAllEmployees.Add(HourlyPromoteForSalary);

                        FirstMessage();

                        ShowEmployees(listOfAllEmployees);

                        ReturnToMainMenu();

                        Console.ReadKey();

                        Console.Clear();

                        repeatMenu = true;

                        break;

                    case "Salary":

                        var SalaryPromotedForManager = new Manager();

                        SalaryPromotedForManager.Name = listOfAllEmployees[idForPromote - 1].Name;

                        SalaryPromotedForManager.Id = listOfAllEmployees[idForPromote - 1].Id;

                        Console.WriteLine($"\tPlease enter a constant payment for {SalaryPromotedForManager.Name}");

                        var constantPaymentUserInput = Console.ReadLine();

                        SalaryPromotedForManager.constantPayment = ParsingForDouble(constantPaymentUserInput);

                        Console.WriteLine($"\tPlease enter a variabl payment for {SalaryPromotedForManager.Name}");

                        var variablPaymentUserInput = Console.ReadLine();

                        SalaryPromotedForManager.variablPayment = ParsingForDouble(variablPaymentUserInput);

                        SalaryPromotedForManager.Salary = SalaryPromotedForManager.Payment;

                        listOfAllEmployees.RemoveAt(idForPromote - 1);

                        listOfAllEmployees.Add(SalaryPromotedForManager);

                        FirstMessage();

                        ShowEmployees(listOfAllEmployees);

                        ReturnToMainMenu();

                        Console.ReadKey();

                        Console.Clear();

                        repeatMenu = true;

                        break;

                    case "Manager":

                        var managerPromotedForExecutive = new Executive();

                        managerPromotedForExecutive.Name = listOfAllEmployees[idForPromote - 1].Name;

                        managerPromotedForExecutive.Id = listOfAllEmployees[idForPromote - 1].Id;

                        Console.WriteLine($"\tPlease enter a number of shares for {managerPromotedForExecutive.Name}");

                        var numberOfSharesUserInput = Console.ReadLine();

                        managerPromotedForExecutive.numberOfShares = ParsingForDouble(numberOfSharesUserInput);

                        Console.WriteLine($"\tPlease enter income per shares for {managerPromotedForExecutive.Name}");

                        var incomePerShareUserInput = Console.ReadLine();

                        managerPromotedForExecutive.incomePerShare = ParsingForDouble(incomePerShareUserInput);

                        managerPromotedForExecutive.Salary = managerPromotedForExecutive.Payment;

                        listOfAllEmployees.RemoveAt(idForPromote - 1);

                        listOfAllEmployees.Add(managerPromotedForExecutive);

                        FirstMessage();

                        ShowEmployees(listOfAllEmployees);

                        ReturnToMainMenu();

                        Console.ReadKey();

                        Console.Clear();

                        repeatMenu = true;


                        break;

                    default:
                        break;
                    }

                    break;

                //Close the app
                case "4":

                    CloseTheApp();

                    break;

                //wrong input
                default:

                    Console.WriteLine("\n\tYou've entered unknown operation. \n\tPlease type any key and you will be redirected to the main menu");

                    Console.ReadKey();

                    Console.Clear();

                    repeatMenu = true;

                    break;
                }
            }
        }