要为某个公司编写雇员( n个雇员)支付月工资,这个公司有各种类型的雇员(Employee),不同类型的雇员按不同的方式支付工资:
时间: 2024-04-08 13:10:46 浏览: 13
1. 全职员工(FullTimeEmployee)按月发放固定工资;
2. 兼职员工(PartTimeEmployee)按小时计算工资;
3. 销售员(SalesEmployee)除了固定工资还有销售提成;
4. 经理(Manager)除了固定工资还有管理津贴。
需要编写一个函数,输入一个雇员列表和当前月份,输出该月份公司需要支付的总工资。函数的伪代码如下:
```
function calculateTotalSalary(employeeList, currentMonth) {
totalSalary = 0
for each employee in employeeList:
if employee is FullTimeEmployee:
totalSalary += employee.getFixedSalary()
else if employee is PartTimeEmployee:
totalSalary += employee.getHoursWorked() * employee.getHourlyRate()
else if employee is SalesEmployee:
totalSalary += employee.getFixedSalary() + employee.getSalesCommission(currentMonth)
else if employee is Manager:
totalSalary += employee.getFixedSalary() + employee.getManagementAllowance()
return totalSalary
}
```