class Employee {
private long empno;
private String ename;
private double salary;
private double rate;
public Employee(){}
public Employee(long empno,String ename,double salary,double rate){
this.empno = empno;
this.ename = ename;
this.salary = salary;
this.rate = rate;
}
public double salaryIncValue(){
return this.salary * this.rate;
}
public double salaryIncResult(){
this.salary = this.salary * (1 + this.rate);
return this.salary;
}
public String getInfo(){
return "雇员编号:" + this.empno + ",姓名:" + this.ename + ",薪水:" + this.salary + ",增长率:" + this.rate;
}
}
public class HelloWorld {
public static void main(String[] args){
Employee emp = new Employee(7369L,"史密斯",3000.0,0.3);//7369原本是整型,加上"L"变成了long型
System.out.println(emp.getInfo());
System.out.println("工资调整额度:" + emp.salaryIncValue());
System.out.println("工资调整后金额:" + emp.salaryIncResult());
System.out.println(emp.getInfo());
}
}
标签:salary,ename,案例,double,面向对象,rate,5.20,Employee,public
From: https://www.cnblogs.com/pansidong/p/17453020.html