//抽象父类
abstract class Employme
{
private String name;
private String id;
private double pay;
Employme(String name,String id,double pay){
this.name=name;
this.id=id;
this.pay=pay;
System.out.println(name+"\n"+id+"\n"+pay);
}
//get和set方法
public String get(){
return name;
}
public void setId(String id){
this.id=id;
}
public String getId(){
return id;
}
public void setPay(double pay){
this.pay=pay;
}
public double getPay(){
return pay;
}
public abstract void work();
}
//子类对象
class Manager extends Employme
{
private double bonus;
//报错点
super(String name,String id,double pay,double bonus);
public void work(){
System.out.println("management"+bonus);
}
}
//子类
class Programmer extends Employme
{
//报错点
super(String name,String id,double pay);
public void work(){
System.out.println("工作");
}
}
//主函数
class Company
{
public static void main(String[] args)
{
String name="如花";
String id="$_9536";
double pay=12304;
double bonus=1234;
Employme p=new Programmer(name,id,pay);
print(p);
Employme p1=new Manager(name,id,pay,bonus);
print(p1);
}
public static void print(Employme p){
p.work();
}
}
报错:---------- javac ----------
Company.java:40: 错误: 非法的类型开始
super(String name,String id,double pay,double bonus);
^
Company.java:48: 错误: 非法的类型开始
super(String name,String id,double pay);
^
2 个错误
|
|