public static CountryPaycheckCalculator GetPaycheckCalculator(Employee employee)
        {
            CountryPaycheckCalculator calculator = null;

            switch (employee.Country.ToLower())
            {
            case "ireland": calculator = new IrelandPayCheckCalculator(); break;

            case "italy": calculator = new ItalyPayCheckCalculator(); break;

            case "germany": calculator = new GermanyPayCheckCalculator(); break;
            }

            return(calculator);
        }
コード例 #2
0
        public void CalculatePaycheck()
        {
            int      id       = EmployeeView.RequestId();
            Employee employee = _repository.GetById(id);

            if (employee != null)
            {
                CountryPaycheckCalculator calculator = CountryPaycheckCalculatorFatory.GetPaycheckCalculator(employee);

                if (calculator != null)
                {
                    Paycheck paycheck = calculator.CalculatePayCheck(employee);
                    EmployeeView.ShowPaycheck(paycheck);
                }
                else
                {
                    EmployeeView.ShowMessage($"O país {employee.Country} não é suportado para cálculo de olerite.");
                }
            }
            else
            {
                EmployeeView.ShowMessage("Funcionário não encontrado.");
            }
        }