-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPillar.java
More file actions
50 lines (38 loc) · 1.31 KB
/
Pillar.java
File metadata and controls
50 lines (38 loc) · 1.31 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
44
45
46
47
48
49
50
package domain.ladder;
import domain.direction.Direction;
import java.util.List;
public class Pillar {
private User user;
private List<Point> points;
public Pillar(User user, List<Point> points) {
this.user = user;
this.points = points;
}
public String getUserName() {
return user.getName();
}
public Direction getPointDirection(int x, int y) {
return getPointByXY(x, y)
.getDirection();
}
private Point getPointByXY(int x, int y) {
return points.stream()
.filter(point -> point.isPresentXY(x, y))
.findFirst()
.orElseThrow(RuntimeException::new);
}
public boolean hasXY(int x, int y) {
return points.stream()
.filter(point -> point.isPresentXY(x, y))
.count() > 0;
}
public static Pillar createFirst(String name, int height) {
return new Pillar(new User(name), PointGenerator.createFirst(height));
}
public static Pillar createMiddle(String name, Pillar before) {
return new Pillar(new User(name), PointGenerator.createMiddle(before.points));
}
public static Pillar createLast(String name, Pillar before) {
return new Pillar(new User(name), PointGenerator.createLast(before.points));
}
}