面向對象來寫,可是不太會,求大神源碼⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯
package com.njupt.www;
import java.util.Date;
public class Employee {
private int num;
private String name;
private String position;
private String date;
private float basic_salary;
private float award;
public Employee()
{
super();
}
public Employee(int num,String name,String position,String date,float basic_salary,float award)
{
super();
this.num=num;
this.name=name;
this.position=position;
this.date=date;
this.basic_salary=basic_salary;
this.award=award;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public float getBasic_salary() {
return basic_salary;
}
public void setBasic_salary(float basic_salary) {
this.basic_salary = basic_salary;
}
public float getAward() {
return award;
}
public void setAward(float award) {
this.award = award;
}
public float getSalary(float basic_salary, float award){
return basic_salary+award;
}
@Override
public String toString() {
return "Employee [num=" + num + ", name=" + name + ", position=" + position + ", date=" + date
+ ", salary=" + getSalary(basic_salary , award) + "]";
}
}
//測試
package com.njupt.www;
public class Test {
public static void main(String[] args) {
Employee employee = new Employee(1001,"李雷","經理","2016-04-15",8000,2000);
System.out.println(employee.toString());
}
}