毕老师的视频,每看一遍都会有不同的收获、看代码:
abstract class employee{//这里的abstract是我自己加的,上一节里面毕老师说抽象方法必须定义在抽象类中,不知道为什么毕老师的视频里面没有。。。
private String name;
private String id;
private double pay;
employee(String name,String id,double pay){
this.name=name;
this.id=id;
this.pay=pay;
}
public abstract void work();
}
class Manager extends Employee{
private int bonus;
Manager(String name,String id,double pay,int bonus){
super(name,id,pay);
this.bonus=bonus;
}
public void work(){
System.out.println("pro work");//总要从这里编译出错,说非法的表达式开始,不懂
}
}
class Pro extends Employee{
Pro(String name,String id,double pay){
super(name,id,pay);
public void work(){
System.out.println("work");
}
}
}
public class EmployeeDemo{
Manager M=new Manager("jingli","01",1.2,5);
Pro P=new Pro("pugong","002",1.0);
}
|
|