You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.3 KiB
43 lines
1.3 KiB
public class Employee {
|
|
private String id;
|
|
private String name;
|
|
private String department;
|
|
private double salary;
|
|
private static final double Min=2000;
|
|
public Employee(String id,String name,String department,double salary) {
|
|
this.id = id;
|
|
this.name = name;
|
|
this.department = department;
|
|
if (salary >= Min) {
|
|
this.salary = salary;
|
|
} else {
|
|
this.salary = Min;
|
|
}
|
|
}
|
|
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>=Min){
|
|
this.salary=salary;
|
|
}else{
|
|
this.salary=Min;
|
|
}
|
|
}
|
|
public void raiseSalary(double percent) {
|
|
if (percent < 0) {
|
|
System.out.println("本次涨薪无效");
|
|
return;
|
|
}
|
|
double newSalary = this.salary * (1 + percent / 100);
|
|
if (newSalary >= Min) {
|
|
this.salary = newSalary;
|
|
} else {
|
|
this.salary = Min;
|
|
}
|
|
}
|
|
}
|
|
|