程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程解疑 >> java源碼-求大神告訴源碼,真的不太會

java源碼-求大神告訴源碼,真的不太會

編輯:編程解疑
求大神告訴源碼,真的不太會

面向對象來寫,可是不太會,求大神源碼⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯圖片說明

最佳回答:


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());


}

}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved