-
Notifications
You must be signed in to change notification settings - Fork 738
Expand file tree
/
Copy pathPoint.java
More file actions
38 lines (30 loc) · 927 Bytes
/
Point.java
File metadata and controls
38 lines (30 loc) · 927 Bytes
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
package nextstep.ladder.domain;
public class Point {
private final boolean left;
private final boolean right;
public Point(boolean left, boolean right) {
validate(left, right);
this.left = left;
this.right = right;
}
private void validate(boolean left, boolean right) {
if (left && right) {
throw new IllegalArgumentException("좌 우 모두 이동 가능한 Point 생성 불가");
}
}
public static Point createLeftmost(boolean canMoveRight) {
return new Point(false, canMoveRight);
}
public Point createRightmost() {
return new Point(this.right, false);
}
public Point createNext(boolean canMoveRight) {
return new Point(this.right, !this.right && canMoveRight);
}
public boolean canMoveLeft() {
return left;
}
public boolean canMoveRight() {
return right;
}
}