public class Employee {
private int id;
private String name;
private double salary;
private Department dept;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public Department getDept() {
return dept;
}
public void setDept(Department dept) {
this.dept = dept;
}
public void countSalary(double sales){
System.out.print("本月的工资为:");
System.out.println(salary + salary<100000?(sales * 0.01):
salary<200000?(sales * 0.02):
(sales * 0.03)
);
}
}
public class Department {
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public class Test {
public static void main(String[] args) {
Employee emp = new Employee();
emp.setSalary(2000);
emp.countSalary(130000);
}
}