File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
src/moving-between-classes/customer Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -5,21 +5,25 @@ const dateToday = () => new Date();
5
5
export class Customer {
6
6
constructor ( name , discountRate ) {
7
7
this . _name = name ;
8
- this . _discountRate = discountRate ;
8
+ this . _setDiscountRate ( discountRate ) ;
9
9
this . _contract = new CustomerContract ( dateToday ( ) ) ;
10
10
}
11
11
12
12
get discountRate ( ) {
13
13
return this . _discountRate ;
14
14
}
15
15
16
+ _setDiscountRate ( aNumber ) {
17
+ this . _discountRate = aNumber ;
18
+ }
19
+
16
20
becomePreferred ( ) {
17
- this . _discountRate += 0.03 ;
21
+ this . _setDiscountRate ( this . discountRate + 0.03 ) ;
18
22
// other nice things
19
23
}
20
24
21
25
applyDiscount ( amount ) {
22
- const discountValue = amount . multiply ( this . _discountRate ) ;
26
+ const discountValue = amount . multiply ( this . discountRate ) ;
23
27
return amount . subtract ( discountValue ) ;
24
28
}
25
29
}
You can’t perform that action at this time.
0 commit comments