-
Notifications
You must be signed in to change notification settings - Fork 566
Expand file tree
/
Copy pathStudyCafeLockerPass.java
More file actions
43 lines (33 loc) · 1.02 KB
/
StudyCafeLockerPass.java
File metadata and controls
43 lines (33 loc) · 1.02 KB
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
package cleancode.studycafe.tobe.model;
public class StudyCafeLockerPass {
private final int duration;
private final int price;
private boolean selected;
private StudyCafeLockerPass(int duration, int price) {
this.duration = duration;
this.price = price;
}
private static StudyCafeLockerPass of(int duration, int price) {
return new StudyCafeLockerPass(duration, price);
}
public static StudyCafeLockerPass fromValues(String[] values) {
int duration = Integer.parseInt(values[1]);
int price = Integer.parseInt(values[2]);
return StudyCafeLockerPass.of(duration, price);
}
int getPrice() {
return selected ? price : 0;
}
public boolean isCompatible(int passDuration) {
return duration == passDuration;
}
void select() {
selected = true;
}
boolean isSelected() {
return selected;
}
String toMenuString() {
return StudyCafePassType.FIXED.toMenuString(duration, price);
}
}