-
Notifications
You must be signed in to change notification settings - Fork 738
Expand file tree
/
Copy pathLine.java
More file actions
43 lines (34 loc) · 1.1 KB
/
Line.java
File metadata and controls
43 lines (34 loc) · 1.1 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 nextstep.ladder.domain;
import java.util.ArrayList;
import java.util.List;
public class Line {
private final ArrayList<LineState> points;
public Line(int countOfParticipant) {
this(generateRandomLine(countOfParticipant));
}
private static ArrayList<LineState> generateRandomLine(int countOfParticipant) {
ArrayList<LineState> line = new ArrayList<>();
LineState firstPoint = new LineState(false, false); // 사다리 라인의 맨 왼쪽은 생성될 수 없다.
line.add(firstPoint);
for (int i = 1; i < countOfParticipant; i++) {
LineState point = LineState.previousOf(line.get(i-1).getCurrent());
line.add(point);
}
return line;
}
public Line(ArrayList<LineState> points) {
this.points = points;
}
public List<LineState> getPoints() {
return points;
}
public LineState getPointsByIndex(int index) {
return points.get(index);
}
@Override
public String toString() {
return "Line{" +
"points=" + points +
'}';
}
}