合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
定义并测试一个代表员工的Employee类。员工属性包括“编号”、“姓名”、“基本工资”、”工资增长率“,还包括计算薪水增长额及计算增长后的工资总额的操作方法。 ```java //员工类 public class Employee{ private long eid; private String ename; private double salary; private double rate; public Employee() { } public Employee(long eid,String ename,double salary,double rate) { this.eid=eid; this.ename=ename; this.salary=salary; this.rate=rate; } public String getInfo() { return "编号:"+this.eid + "、姓名:"+this.ename+"、工资:"+this.salary+"、增长率:"+this.rate; } public double salaryRate() { return this.salary*this.rate; } public double salaryadd() { this.salary=this.salary*(1+this.rate); return this.salary; } } //测试类 public class Test { public static void main(String args[]) { Employee emp = new Employee(134L,"张三",3000.0,0.3); System.out.println(emp.getInfo()); System.out.println("工资调整额度:"+emp.salaryRate()); System.out.println("上调后的工资:"+emp.salaryadd()); System.out.println(emp.getInfo()); } } ```