不晓得错误在哪,大家帮忙找找。
public interface IEmployee{//设置员工加薪基准值常量
public static final double prize=1000.00;
//声明给员工加薪的方法
public abstract void addSalary();
}
上面定义的是接口IEmployee
———————————————————————————————————
class Employee implements IEmployee{
private String name; //姓名属性
private double salary; //雇员薪水
private String hireDay; //雇员入职时间
//含有参数的构造方法
public Employee(String name,double salary,String hireDay){
this.name=name;
this.salary=salary;
this.hireDay=hireDay;
}
//用于获取雇员信息的方法
public String getName(){
return name;
}
public void getInfo(){
System.out.println("I'm Employee");
}
public double getsalary(){
return salary;
}
public String gethireDay(){
return hireDay;
}
//定义接口中实现抽象方法
public void addSalary(int n){
salary+=prize*n;
}
}
public class UseIEmployee{
public static void main(String ages[]){
Employee e1=new Employee("张三",3000.00,"2005/05/20");
e1.addSalary(1);
System.out.println("name:"+e1.getName());
e1.getInfo();
System.out.println("salary:"+e1.getsalary());
System.out.println("hireDay:"+e1.gethireDay()+"\n");
Employee e2=new Employee("李四",5000.00,"2006/06/10");
e2.addSalary(5);
System.out.println("name:"+e2.getName());
e2.getInfo();
System.out.println("salary:"+e2.getsalary());
System.out.println("hireDay:"+e2.gethireDay()+"\n");
}
}
接口类的实现UserIEmployee.java
但是运行结果
UseIEmployee.java:1: Employee 不是抽象的,并且未覆盖 IEmployee 中的抽象方法 addS
alary()
class Employee implements IEmployee{
^
1 错误
大家帮忙看看,Employee里
public void addSalary(int n){
salary+=prize*n;
} 这段应该是覆盖了抽象方法的吧,为上面不能编译?