-
Notifications
You must be signed in to change notification settings - Fork 738
Expand file tree
/
Copy pathLadder.java
More file actions
34 lines (24 loc) · 800 Bytes
/
Ladder.java
File metadata and controls
34 lines (24 loc) · 800 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
package nextstep.ladder.domain;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Ladder {
private static final String HEIGHT_ERROR_MESSAGE = "높이는 0보다 커야 합니다.";
private List<Line> lines;
public Ladder(int height, int width) {
if (1 > height) {
throw new IllegalArgumentException(HEIGHT_ERROR_MESSAGE);
}
this.lines = createLines(height, width);
}
public List<Line> getLines() {
return Collections.unmodifiableList(this.lines);
}
private List<Line> createLines(int height, int width) {
List<Line> lines = new ArrayList<>();
for (int i = 0; i < height; i++) {
lines.add(new Line(width));
}
return lines;
}
}