abstract class Employee
{
//姓名
String name;
//职位
String position;
//地址
String address;
Employee(){}
//用于显示属性
abstract void show();
}
class Manager extends Employee
{
//部门
String department;
Manager(){}
Manager(String name,String position,String address,String department)
{
this.name = name;
this.position = position;
this.address = address;
this.department = department;
}
void show()
{
System.out.println(name+" "+position+" "+address+" "+department);
}
}
class Director extends Employee
{
//补助
double transportAllowance;
Director(){}
Director(String name,String position,String address,double transportAllowance)
{
this.name = name;
this.position = position;
this.address = address;
this.transportAllowance = transportAllowance;
//听 说这里可以用super();代替。但是这个super()到底是怎么来的?怎么代入进去的?求解!
}
void show()
{
System.out.println(name+" "+position+" "+address+" "+transportAllowance);
}
}
class AbstractTest
{
public static void main(String[] args)
{
//抽象类不能够实例化
//Employee e = new Employee();
Manager m = new Manager("黄岩岛","经理","南海","外交部");
m.show();
Director d = new Director("钓鱼岛","程序员","东海",123456789.0);
d.show();
}
}
|