JavaSE进阶

6)Employee类及其子类Designer和Architect

package com.atguigu.bean;

public class Designer extends Programmer{

    private double bonus;

    public Designer() {

    }

    public Designer(int id, String name, int age, double salary,

                     Equipment equipment, double bonus) {

        super(id, name, age, salary, equipment);

        this.bonus = bonus;

    }

    public double getBonus() {

        return bonus;

    }

    public void setBonus(double bonus) {

        this.bonus = bonus;

    }

    @Override

    public String toString() {

        return getDetails() + "\t设计师\t" + getStatus() + "\t" +

               getBonus() +"\t\t" + getEquipment();

    }

}

package com.atguigu.bean;

public class Architect extends Designer {

    private int stock;

    public Architect() {

    }

    public Architect(int id, String name, int age, double salary,

                      Equipment equipment, double bonus, int stock) {

        super(id, name, age, salary, equipment, bonus);

        this.stock = stock;

    }

    public int getStock() {

        return stock;

    }

    public void setStock(int stock) {

        this.stock = stock;

    }

    @Override

    public String toString() {

        return getDetails() + "\t架构师\t" + getStatus() + "\t" +

               getBonus() + "\t" + getStock() + "\t" + getEquipment();

    }

}

格式控制:

    @Override

    public String toString() {

        return getDetails() + "\t设计师\t" + getStatus() + "\t" +

               getBonus() +"\t\t" + getEquipment();

    }

    @Override

    public String toString() {

        return getDetails() + "\t架构师\t" + getStatus() + "\t" +

               getBonus() + "\t" + getStock() + "\t" + getEquipment();

    }