-
Notifications
You must be signed in to change notification settings - Fork 0
/
MoveField.java
90 lines (72 loc) · 2.43 KB
/
MoveField.java
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
78
79
80
81
82
83
84
85
86
87
88
89
90
package move;
/**
* Move Field
*
* 필드 옮기기
*/
public class MoveField {
static class Old {
static class Customer {
private String name;
private double discountRate;
private CustomerContract contract;
public Customer(String name, double discountRate, CustomerContract contract) {
this.name = name;
this.discountRate = discountRate;
this.contract = contract;
}
public double getDiscountRate() {
return discountRate;
}
public void becomePreferred() {
this.discountRate += 0.03;
}
public double applyDiscount(int amount) {
return amount - (amount / this.discountRate);
}
}
static class CustomerContract {
private String startDate;
public CustomerContract(String startDate) {
this.startDate = startDate;
}
}
}
static class New {
static class Customer {
private String name;
private CustomerContract contract;
public Customer(String name, double discountRate) {
this.name = name;
this.contract = new CustomerContract("test", discountRate);
setDiscountRate(discountRate);
}
public void setDiscountRate(double discountRate) {
this.contract.setDiscountRate(discountRate);
}
public double getDiscountRate() {
return this.contract.getDiscountRate();
}
public void becomePreferred() {
setDiscountRate(getDiscountRate() + 0.03);
}
public double applyDiscount(int amount) {
return amount - (amount / this.getDiscountRate());
}
}
static class CustomerContract {
private String startDate;
private double discountRate;
public CustomerContract(String startDate, double discountRate) {
this.startDate = startDate;
this.discountRate = discountRate;
}
public double getDiscountRate() {
return discountRate;
}
public void setDiscountRate(double discountRate) {
this.discountRate = discountRate;
}
}
}
}