⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 employee.java

📁 在作业1的Employee和EmployeeDemo两个类基础上修改 1
💻 JAVA
字号:
package com.totyuedu.c69.a20080829;

public class Employee {

    private String name;

    private int age;

    private double salary;

    private String tel;

    private String address;

    private String position;

    private String department;

    private String boss;

    public Employee() {
    }

    public Employee(String name, int age, double salary, String tel,
            String address, String position, String department, String boss) {
        super();
        this.name = name;
        this.age = age;
        this.salary = salary;
        this.tel = tel;
        this.address = address;
        this.position = position;
        this.department = department;
        this.boss = boss;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getBoss() {
        return boss;
    }

    public void setBoss(String boss) {
        this.boss = boss;
    }

    public void setBoss(Employee boss) {
        this.boss = boss.getName();
    }

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String toString() {

        StringBuffer sb = new StringBuffer();

        sb.append("Employee Infomation:\n");
        sb.append("Name:" + getName() + "\n");
        sb.append("Address:" + getAddress() + "\n");
        sb.append("Position:").append(getPosition()).append("\n");
        sb.append("Tel:" + getTel() + "\n");
        sb.append("Salary:" + getSalary() + "\n");
        sb.append("Department:" + getDepartment() + "\n");

        return sb.toString();
    }

    public boolean equals(Object o) {
        if (!(o instanceof Employee)) {
            return false;
        }

        if (o == this) {
            return true;
        }

        Employee e = (Employee) o;

        if ((e.getName() != null && e.getName().equals(getName()))
                && (e.getDepartment() != null && e.getDepartment().equals(
                        getDepartment()))) {
            return true;
        }
        return false;
    }

    public double getBonus() {
        // 普通员工年终奖金分配方案为月薪×2
        return getSalary() * 2;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -