JAVA OOP问题

来源:百度知道 编辑:UC知道 时间:2024/06/04 06:22:43
创建一个Employee类(抽象类)
属性: 姓名 name
薪水 salary

还包含一个抽象方法(用来计算周工资)。 abstract public double calcSalary();

派生XSworker(小时工): 按小时支付工资,若每周工作超过40小时,超出部分按1.5支付。
属性: 周工作的小时数 hours
每小时的工资 hourSalary

派生JJworker(计件工): 按产品数量支付。
属性: 产品数量 quantity
每件产品薪水 quantitySalary

派生YJworker(佣金工): 有固定保底周薪,再按照每周销售额提成10%。
属性: 底薪: basePay
销售额: salesMoney

派生Boss(老 板): 每周获得固定周薪
属性: 固定周薪 solidPay

==========全部通过构造函数初始化数据。=======
还有一个输出信息的方法 show 在父类中定义,子类重写
来不及了 明天要交了。。。。汗~玩WOW玩过头了

public abstract class Employee {
  protected String name = "";

  protected double salary = 0l;

  public Employee() {

  }

  public abstract double calcSalary();

  public abstract void show();

  /**
  * @return Returns the name.
  */
  public String getName() {
  return name;
  }

  /**
  * @param name The name to set.
  */
  public void setName(String name) {
  this.name = name;
  }

  /**
  * @return Returns the salary.
  */
  public double getSalary() {
  return salary;
  }

  /**
  * @param salary The salary to set.
  */
  public void setSalary(double salary) {
  this.salary = salary;
  }

  }
  ========================

  public class XSworker extends Employee {

  private int hours =0;

  private long hourSalary =0l;