1.5 重點
package Employ;
public class EmpDemo {
public static void main(String[] args) {
Emp emp =new Emp(1001,"張三豐",1000,200);
Emp emp1 = new Emp(1002,"張無忌",2000,300);
System.out.println(emp.Information());
System.out.println(emp1.Information());
}
}
class Emp{
private int empno ;
private String name ;
private float salary ;
private float bonus ;
public Emp() {}
public Emp(int empno, String name, float salary, float bonus) {
super();
this.empno = empno;
this.name = name;
this.salary = salary;
this.bonus = bonus;
}
public int getEmpno() {
return empno;
}
public void setEmpno(int empno) {
this.empno = empno;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public float getSalary() {
return salary;
}
public void setSalary(float salary) {
this.salary = salary;
}
public float getBonus() {
return bonus;
}
public void setBonus(float bonus) {
this.bonus = bonus;
}
public float salary1(){ //月薪
return salary+bonus;
}
public float daily(){ //日薪
return this.salary1()/30;
}
public float income(){ //年薪
return this.salary1()*12;
}
public String Information(){
return "員工信息:\n"+"\tl- 員工編號:"+this.getEmpno()+"\n"+"\tl- 員工姓名"+this.getName()+"\n"+"\tl- 員工薪水:"+this.getSalary()+"\n"+"\tl- 獎金:"+this.getBonus()+
"\n"+"\tl- 日薪:"+this.daily()+"\n"+"\tl- 月薪:"+this.salary1()+"\n"+"\tl- 年薪:"+this.income();
}
}
1.5 重點