本帖最后由 杨晓燕 于 2013-4-26 19:39 编辑
- abstract class Employee
- {
- 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)
- {
- super(name,id,pay);
- this.bonus=bonus;
- }
- public void work()
- {
- System.out.println("Manager work");
- }
- class Pro extends Employee
- {
- Pro(String name,String id,double pay)
- {
- super(name,id,pay);
- }
- public void work()
- {
- System.out.println("Pro work");
- }
- }
- }
- class EmployeeDemo
- {
- public static void main(String[] args)
- {
- Pro p=new Pro("yang","789a",5000);
- p.work();
- //System.out.println();
- }
- }
复制代码 求详细解释 |
|