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. 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.
2. 建立一个class “Worker” 包括 hours (工作时间), wages(每小时工资)
3. 建立一个class “ SalesMan” 包括 sales(销售额),commission percent(佣金百分率)
4. 建立一个class “ Roll” 连接以上class , 然后能输出详细信息
public class Employee{
pravite String id;
pravite String name;
pravite String gender;
pravite String job; public Employee(){
}
public Employee(String id,String name,String gender,String job){
this.id = id;
this.name = name;
this.gender = gender;
this.job = job;
}
public void setId(String id){
this.id = id;
}
public void getId(){
return id;
}
public void setName(String name){
this.name = name;
}
public void getName(){
return name;
}
public void setGender(String gender){
this.gender = gender;
}
public void getGender(){
return gender;
}
public void setJob(String job){
this.job = job;
}
public void getJobr(){
return job;
}
}
public class Worker{
private Double hours;
private Double wages;
public Worker(){}
public Worker(Double hours,Double wages){
this.hours = hours;
this.wages = wages;
}
public void setHours(Double hours){
this.hours = hours;
}
public Double getHours(){
return hours;
}
public void setWages(Double wages){
this.wages = wages;
}
public Double getWages(){
return wages;
}
}public class SalesMan{ private Double sales;
private Double percent;
public void SalesMan(){}
public void SalesMan(Double sales,Double percent){
this.sales = sales;
this.percent = percent;
}
public void setSales(Double sales){
this.sales = sales;
}
public Double getSales(){
return sales;
}
public void setPercent(Double percent){
this.percent = percent;
}
public Double getPercent(){
return percent;
}
}public class Roll{ public static main(String[] agr){
Employee employee = new Employee("id","name","gender","job");
Worker worker = new Worker(new Double(40),new Double(200));
SalesMan salesMan = new SalesMan(new Double(100000),new Double(0.01));
System.out.println("Employee: Id=" + employee.getId() + " Name=" + employee.getName() );
System.out.println("Worker: Hours=" + worker.getHours().toString() + " Wages=" + worker.getWages().toString() );
System.out.println("SalesMan: Sales=" + salesMan.getSales().toString() + " Percent" + salesMan.getPercent().toString() );
}
}