-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod09 Employee
77 lines (71 loc) · 1.47 KB
/
mod09 Employee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.khh.gjun;
public class Employee {
//屬性Attribute
//封裝性設定 資訊隱藏 物件化(non-static)
//private-modifier修飾詞 現這一個類別可見
private int id;
private String name;
private String address;
private double salary; //底薪
//實際薪資(月薪)
private double actSalary; //經過計算
//沒有寫建構子 編譯產生預設建構子 Employee()
//方法method 程序
//setter 設定
public void setId(int id)
{
this.id=id;
}
//getter
public int getId()
{
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public double getSalary() {
return salary;
}
//底薪合理化
public void setSalary(double salary) {
//邏輯判斷
if(salary>=50000){
this.salary = salary;
}else
{
this.salary=50000;
}
}
//getter 唯讀屬性
public double getActSalary()
{
return actSalary;
}
//實際薪資 需要經過較為複雜的方法計算--Business Rule商業規則方法
//架構 簽章 另一個本體 實作
/**
* 薪資核算方法
* @param days:int 出勤天數
*/
public void calSalary(int days)
{
//全勤22天
if(days>=0){
actSalary=(days/22.0)*salary;
}//輸入內容出勤天數不合理 擲出例外物件給應用系統
}
public void calSarlay(double hours)
{
ActSalary=hours*500;
}
}