本题中带两个参数的构造函数要求接受一个雇员所需的所有字段作为参数,并在其中调用CreateNewEmpolyee()方法。我的问题是不会在这个构造函数中调用CreateNewEmpolyee()方法,因为这个方法内的参数我怎么也传不进去!请大家帮忙,谢谢! using System;
class zuoYe1 { int EmployeeNo; int DaysPresent=3; string EmployeeName; string Department; string Designation; double HRA; double PF=5; double Salary; double EmployeeBasic;
public zuoYe1() { Department="SoftWare"; }
public zuoYe1(int eNo2,string eName2,string depart2,string design2) { this.CreateNewEmployee(int eNo2,string eName2,string depart2,string design2); //这里就是 我出错的地方,参数不知怎么传 }
public void CreateNewEmployee(int eNo,string eName,string depart,string design) { EmployeeNo=eNo; EmployeeName=eName; Department=depart; Designation=design; switch(Designation) { case("Manager"): EmployeeBasic=10000; HRA=2000; break; case("System Analyst"): EmployeeBasic=8000; HRA=1500; break; case("Project Leader"): EmployeeBasic=6000; HRA=1000; break; case("Programmer"): EmployeeBasic=5000; HRA=500; break; default: Console.WriteLine("您输入有错误,请重输!"); break; } }
public void ShowEmpInfo(int eNo) { Console.WriteLine("您的雇员号是:{0},您的姓名是:{1},您的部门是:{2},您的职位是:{3}",EmployeeNo,EmployeeName,Department,Designation); }
public void ShowEmpInfo(int eNo,int dPresent) { Salary=((EmployeeBasic/30)*DaysPresent)+((HRA/30)*DaysPresent)-PF; Console.WriteLine("您的雇员号是:{0},基本工资是:{1},HRA是:{2},工资是: {3}",EmployeeNo,EmployeeBasic,HRA,Salary); }
public static void Main(String[] args) { zuoYe1 zy1=new zuoYe1(001,"梅青","市场部","Project Leader"); zy1.ShowEmpInfo(001); zy1.ShowEmpInfo(001,25); //zuoYe1 zy2=new zuoYe1(); //zy2.CreateNewEmployee(002,"李伟","开发部","System Analyst"); //zy2.ShowEmpInfo(002); //zy2.ShowEmpInfo(002,30); } }
[此贴子已经被goodgoodstudy于2005-8-11 21:09:58编辑过]