1 changed files with 87 additions and 0 deletions
@ -0,0 +1,87 @@ |
|||
public class Employee { |
|||
private static String companyName; |
|||
private String ID; |
|||
private String name; |
|||
private String department; |
|||
private double salary; |
|||
public static void setCompanyName(String name){ |
|||
companyName = name; |
|||
} |
|||
public static String getCompanyName(){ |
|||
return companyName; |
|||
} |
|||
public Employee(String ID,String name,String department,double salary){ |
|||
this.ID=ID; |
|||
this.name=name; |
|||
this.department=department; |
|||
if(salary<2000){ |
|||
System.out.println("初始工资低于最低标准"); |
|||
}else{ |
|||
this.salary=salary; |
|||
} |
|||
} |
|||
public String getID(){ |
|||
return ID; |
|||
} |
|||
public void setID(String ID){ |
|||
this.ID=ID; |
|||
} |
|||
public String getName(){ |
|||
return name; |
|||
} |
|||
public void setName(String name){ |
|||
this.name=name; |
|||
} |
|||
public String getDepartment(){ |
|||
return department; |
|||
} |
|||
public void setDepartment(String department){ |
|||
this.department=department; |
|||
} |
|||
public double getSalary(){ |
|||
return salary; |
|||
} |
|||
public void setSalary(double salary){ |
|||
if(salary<2000){ |
|||
System.out.println("不可以低于最低工资标准"); |
|||
} |
|||
else{ |
|||
this.salary=salary; |
|||
} |
|||
} |
|||
public void raiseSalary(double percent){ |
|||
this.salary*=(100+percent)/100; |
|||
if(this.salary<2000){ |
|||
System.out.println("仍小于最低工资标准"); |
|||
} |
|||
} |
|||
public void info(){ |
|||
System.out.println("公司名称:" + companyName); |
|||
System.out.println("员工ID:"+ID); |
|||
System.out.println("员工姓名:"+name); |
|||
System.out.println("员工部门:"+department); |
|||
System.out.println("员工工资:"+salary); |
|||
} |
|||
public static void main(String[] args){ |
|||
Employee.setCompanyName("科技有限公司"); |
|||
Employee emp1 = new Employee("1001", "张三", "技术部", 5000); |
|||
System.out.println("===== 员工1 初始信息 ====="); |
|||
emp1.info(); |
|||
emp1.setDepartment("产品部"); |
|||
emp1.setSalary(7000); |
|||
System.out.println("===== 修改后信息 ====="); |
|||
emp1.info(); |
|||
System.out.println("===== 尝试设置非法工资 ====="); |
|||
emp1.setSalary(1800); |
|||
emp1.info(); |
|||
emp1.raiseSalary(20); |
|||
System.out.println("===== 涨薪20%后 ====="); |
|||
emp1.info(); |
|||
Employee emp2 = new Employee("1002", "李四", "市场部", 2000); |
|||
System.out.println("===== 员工2 初始信息(最低工资) ====="); |
|||
emp2.info(); |
|||
emp2.raiseSalary(5); |
|||
System.out.println("===== 涨薪5%后 ====="); |
|||
emp2.info(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue