-
Notifications
You must be signed in to change notification settings - Fork 743
/
Copy pathLines.java
37 lines (29 loc) · 1 KB
/
Lines.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
package nextstep.ladder.domain;
import nextstep.ladder.domain.strategy.GenerateLadderPoint;
import nextstep.ladder.domain.strategy.RandomLadderPoint;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class Lines {
private List<Line> lines;
public Lines() {
}
public void initialize(int size, Height height, GenerateLadderPoint generateLadderPoint) {
this.lines = createLines(size, height, generateLadderPoint);
}
public int move(int position) {
for (Line line : lines) {
position = line.move(position);
}
return position;
}
private List<Line> createLines(int size, Height height, GenerateLadderPoint generateLadderPoint) {
return IntStream.range(0, height.getPoint())
.mapToObj(i -> new Line(size, generateLadderPoint))
.collect(Collectors.toList());
}
public List<Line> getLines() {
return lines;
}
}