-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathLadder.java
More file actions
36 lines (30 loc) · 1010 Bytes
/
Ladder.java
File metadata and controls
36 lines (30 loc) · 1010 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
package domain;
import java.util.ArrayList;
import java.util.List;
public class Ladder {
private final Lines lines;
public Ladder(LadderHeight height, LadderWidth width) {
this.lines = new Lines(createLines(height, width));
}
private List<Line> createLines(LadderHeight height, LadderWidth width) {
List<Line> list = new ArrayList<>();
Line previousLine = null;
for (int i = 0; i < height.getValue(); i++) {
Line current = new Line(width, previousLine);
list.add(current);
previousLine = current;
}
return list;
}
public List<String> getLadderBody() {
return lines.drawAll();
}
public LadderResult play() {
int columnCount = lines.getColumnCount();
List<Position> positions = new ArrayList<>();
for (int i = 0; i < columnCount; i++) {
positions.add(lines.moveAll(new Position(i)));
}
return new LadderResult(positions);
}
}