Esempio n. 1
0
        public IEmployee CreateEmployee(EmployeeBuilderContract contract)
        {
            IEmployee toReturn;

            switch (contract.Type)
            {
            case EmployeeType.Contract:
                toReturn            = new ContractEmployee(contract.WeeklyHourAllotment, contract.HourlyRate);
                toReturn.Department = "Department";
                break;

            case EmployeeType.Hourly:
                toReturn            = new HourlyEmployee(contract.WeeklyHourAllotment, contract.HourlyRate);
                toReturn.Department = "Department";
                break;

            case EmployeeType.Salary:
                toReturn            = new SalaryEmployee(contract.YearlyRate);
                toReturn.Department = "Department";
                break;

            default:
                throw new ArgumentException("Employee type invalid");
            }

            return(toReturn);
        }
        public IEmployee CreateEmployee(EmployeeBuilderContract contract)
        {
            switch (contract.Type)
            {
            case EmployeeType.Contract:
                return(new ContractEmployee(contract.WeeklyHourAllotment, contract.HourlyRate));

            case EmployeeType.Hourly:
                return(new HourlyEmployee(contract.WeeklyHourAllotment, contract.HourlyRate));

            case EmployeeType.Salary:
                return(new SalaryEmployee(contract.YearlyRate));

            default:
                throw new ArgumentException("Employee type invalid");
            }
        }