All class are supported with default constructor, proper constructor, set, get and toString method.
1. create a class “Employee” having id ,name ,gender, and job.
2. create a subclass “Worker” having hours worked, wages per hour. Write getSalary method to salary.
3. create a subclass “SalesMan” having sales and commission percent . Write getCommission method to  calculate salary.
4. create a client class “Roll” to have any employee by identifying using menu to print salary details. Input can be random , but collect Worker and SalesMan details separately.

解决方案 »

  1.   


    public class Employee {
    private int id; private String name; private String gender; private String job; public String getGender() {
    return gender;
    } public void setGender(String gender) {
    this.gender = gender;
    } public int getId() {
    return id;
    } public void setId(int id) {
    this.id = id;
    } public String getJob() {
    return job;
    } public void setJob(String job) {
    this.job = job;
    } public String getName() {
    return name;
    } public void setName(String name) {
    this.name = name;
    } public Employee() {
    super();
    // TODO Auto-generated constructor stub
    } public Employee(int id, String name, String gender, String job) {
    super();
    this.id = id;
    this.name = name;
    this.gender = gender;
    this.job = job;
    } @Override
    public String toString() {
    return super.toString();
    }}
    public class Worker extends Employee {
    private int hours; private double wages; public Worker() {
    super();
    // TODO Auto-generated constructor stub
    } public Worker(int id, String name, String gender, String job) {
    super(id, name, gender, job);
    // TODO Auto-generated constructor stub
    } public Worker(int hours, double wages) {
    super();
    this.hours = hours;
    this.wages = wages;
    } public Worker(int id, String name, String gender, String job, int hours,
    double wages) {
    this(id, name, gender, job);
    this.hours = hours;
    this.wages = wages;
    } public int getHours() {
    return hours;
    } public void setHours(int hours) {
    this.hours = hours;
    } public double getWages() {
    return wages;
    } public void setWages(double wages) {
    this.wages = wages;
    } public double getSalary() {
    return wages * hours;
    } @Override
    public String toString() {
    // TODO Auto-generated method stub
    return super.toString();
    }
    }
    public class SalesMan extends Employee {
    private float sales; private float percent; public SalesMan(float sales, float percent) {
    super();
    this.sales = sales;
    this.percent = percent;
    } public SalesMan() {
    super();
    // TODO Auto-generated constructor stub
    } public SalesMan(int id, String name, String gender, String job,
    float sales, float percent) {
    super(id, name, gender, job);
    this.sales = sales;
    this.percent = percent;
    // TODO Auto-generated constructor stub
    } public float getPercent() {
    return percent;
    } public void setCommission(float percent) {
    this.percent = percent;
    } public float getSales() {
    return sales;
    } public void setSales(float sales) {
    this.sales = sales;
    } public float getCommission() {
    return sales * percent;
    } @Override
    public String toString() {
    // TODO Auto-generated method stub
    return super.toString();
    }
    }
    public class Roll {
    public static void main(String[] args) {
    //没看懂最后一句是什么意思......
    }
    }
    最后一句看不太懂....应该是一些调用...
      

  2.   

    最后一句,就是让 用Roll把它们 连接起来,然后可以运行(只要能运行,能显示  就OK)
      大家帮帮忙!  
      

  3.   

    还是有点不太懂,你是想写个ROLL类来输出信息么?
      

  4.   

    只要意思:1. 建立一个class “Employee” 包括 id , name ,gender,job,
    2. 建立一个class “Worker” 包括 hours (工作时间), wages(每小时工资)
    3. 建立一个class “ SalesMan”  包括 sales(销售额),commission percent(佣金百分率)
    4. 建立一个class “ Roll”  连接以上class , 然后能输出详细信息
      

  5.   

    最后一个class  "Roll" 哪位朋友  帮帮忙!