1、某公司雇员(Employee)包括经理(Manager),技术人员(Technician)和销售员(Salesman)。 1)Employee类的属性包括姓名、职工号、工资级别(影响基本工资),月薪(基本工资加业绩工资)。操作包括月薪计算函数(Pay()),该函数要求输入请假天数,扣去应扣工资后,得出实发基本工资。 2)Technician类派生的属性有每小时附加酬金和当月工作时数,及工作完成进度系数,业绩工资为三者之积。Technician类也包括Pay()函数,工资总额为基本工资加业绩工资。 3)Salesman类派生的属性有当月销售额和酬金提取百分比,业绩工资为两者之积。Sales
2、man类也包括Pay()函数,工资总额为基本工资加业绩工资。 4)Manager类派生属性有固定奖金额和业绩系数,业绩工资为两者之积。工资总额也为基本工资加业绩工资。 编程实现工资管理。对不同的类的员工,计算相应的工资 using System; using System.Collections.Generic; using System.Linq; using System.Text; using Type_0713.Type; namespace FormulaOfBasicSalary { class Consts {
3、public const string InputLeaveDays1 = "请输入公司雇员Employee本月请假天数:"; public const string PromptError = "你输入的数据不正确"; public const string PromptDayError = "请假的天数不得大于7天或小于0天"; public const string LeaveDays2 = "请输入技术人员Technician本月请假天数:"; public const string InputFinishFact
4、or = "请输入技术人员本月工作完成进度系数:"; public const string FactorError = "工作完成进度系数应在0~1之间"; public const string LeaveDays3 = "请输入销售员Salesman本月请假天数:"; public const string InputSale = "请输入销售员本月销售额:"; public const string SaleError = "销售额不得小于0"; public const string Input
5、LeaveDays4 = "请输入经理Manager本月请假天数:"; public const string InputAchieveFactor = "请输入经理本月业绩系数:"; public const string AchieveFactorError = "业绩系数不得小于0"; public const string PrompButton = "按回车键,输入下条信息"; } class Program { static void Main(string[] args)
6、 { #region 公司雇员Employee类的月薪计算 //输入数据 Console.WriteLine(Consts.InputLeaveDays1); string str = Console.ReadLine(); //验证数据 int day; if (!int.TryParse(str, out day)) { Cons
7、ole.WriteLine(Consts.PromptError); Console.ReadKey(); return; } int days = Convert.ToInt32(str); if (days < 0 || days > 7) { Console.WriteLine(Consts.PromptDayError); Console.ReadK
8、ey(); return; } //处理数据 Employee employee = new Employee(); employee.Pay(days); Console.WriteLine(Consts.PrompButton); Console.ReadKey(); #endregion #region 技术人员Technician工资总
9、额计算 Technician technician = new Technician(); //输入数据 Console.WriteLine(Consts.LeaveDays2); string str1 = Console.ReadLine(); //验证请假天数是否符合要求 int day1; if (!int.TryParse(str1, out day1)) {
10、 Console.WriteLine(Consts.PromptError); Console.ReadKey(); return; } if (day1 < 0 || day1 > 7) { Console.WriteLine(Consts.PromptDayError); Console.ReadKey(); return;
11、 } Console.WriteLine(Consts.InputFinishFactor); string str11 = Console.ReadLine(); //验证工作完成进度系数是否符合要求 double num; if (!double.TryParse(str11, out num)) { Console.WriteLine(Consts.PromptErr
12、or); Console.ReadKey(); return; } //int days1 = Convert.ToInt32(str1); if (num < 0 || num > 1) { Console.WriteLine(Consts.FactorError); Console.ReadKey(); return;
13、 } //计算当月工作时数 technician.MonthWorkHourNum = technician.MonthWorkHourNum - days; //计算工资总额 technician.Pay(day1); Console.WriteLine(Consts.PrompButton); Console.ReadKey(); #endregion
14、 #region 销售员Salesman工资总额计算 Salesman salesman = new Salesman(); //输入数据 Console.WriteLine(Consts.LeaveDays3); string str2 = Console.ReadLine(); Console.WriteLine(Consts.InputSale); string str22 = Console.ReadLine();
15、 //验证请假天数是否符合要求 int day2; if (!int.TryParse(str2, out day2)) { Console.WriteLine(Consts.PromptError); Console.ReadKey(); return; } //int days1 = Convert.ToInt32(str1);
16、 if (day2 < 0 || day2 > 7) { Console.WriteLine(Consts.PromptDayError); Console.ReadKey(); return; } //验证工作完成进度系数是否符合要求 int number; if (!int.TryParse(str22, out number))
17、 { Console.WriteLine(Consts.PromptError); Console.ReadKey(); return; } if (number < 0) { Console.WriteLine(Consts.SaleError); Console.ReadKey(); return;
18、 } //当月销售额 salesman.SalesThatMonth = number; //计算工资总额 salesman.Pay(day2); Console.WriteLine(Consts.PrompButton); Console.ReadKey(); #endregion #region 经理Manager工资总额计算
19、 Manager manager = new Manager(); //输入数据 Console.WriteLine(Consts.InputLeaveDays4); string str3 = Console.ReadLine(); Console.WriteLine(Consts.InputAchieveFactor); string str33 = Console.ReadLine(); //验证请假天数是否符合要求
20、 int day3; if (!int.TryParse(str3, out day3)) { Console.WriteLine(Consts.PromptError); Console.ReadKey(); return; } if (day3 < 0 || day3 > 7) { Console.Writ
21、eLine(Consts.PromptDayError); Console.ReadKey(); return; } //验证业绩系数是否符合要求 double factor; if (!double.TryParse(str33, out factor)) { Console.WriteLine(Consts.PromptError);
22、 Console.ReadKey(); return; } if (factor < 0) { Console.WriteLine(Consts.AchieveFactorError); Console.ReadKey(); return; } //当月销售额 manager.AchieveF
23、actor = factor; //计算工资总额 manager.Pay(day3); Console.ReadKey(); #endregion } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Type_0713.Type { #region 公司雇员(
24、Employee)基类
public class Employee
{
///
25、 {
get;
set;
}
///
26、 BasicSalary
{
get;
set;
}
///
27、summary>
public double MonthlyPay
{
get;
set;
}
///
28、 /// 公司雇员基本工资初始化
///
public Employee()
{
BasicSalary = 3000;
}
///
29、
this.FactBasicSalary = this.BasicSalary - 10 * LeaveDays;
Console.WriteLine("Employee的月薪工资为:{0}元", this.FactBasicSalary);
}
}
#endregion
#region 技术人员(Technician)派生类
public class Technician : Employee
{
///
30、// 每小时附加酬金
///
public double AdditionReward
{
get;
set;
}
///
31、
///
32、d = 1.7;
MonthWorkHourNum = 192;
WorkCompleted = 1;
}
///
33、 this.BasicSalary - 10 * LeaveDays; this.AchieveSalary = AdditionReward * MonthWorkHourNum * WorkCompleted; this.MonthlyPay = this.FactBasicSalary + this.AchieveSalary; Console.WriteLine("Technician的月薪工资为:{0}元", this.MonthlyPay); } } #endreg
34、ion
#region 销售员(Salesman)派生类
public class Salesman : Employee
{
///
35、
public double RemunPercentage
{
get;
set;
}
///
36、 ///
37、munPercentage;
this.MonthlyPay = this.FactBasicSalary + this.AchieveSalary;
Console.WriteLine("Salesman的月薪工资为:{0}元", this.MonthlyPay);
}
}
#endregion
#region 经理(Manager)派生类
public class Manager : Employee
{
///
38、 /// 固定奖金额
///
public double FixedIndAwards
{
get;
set;
}
///
39、 ///
40、 public override void Pay(int LeaveDays) { this.FactBasicSalary = this.BasicSalary - 10 * LeaveDays; this.AchieveSalary = FixedIndAwards * AchieveFactor; this.MonthlyPay = this.FactBasicSalary + this.AchieveSalary; Console.WriteLine("Manager的月薪工资为:{0}元", this.MonthlyPay); } } #endregion }






