-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneration.java
More file actions
46 lines (36 loc) · 932 Bytes
/
Copy pathGeneration.java
File metadata and controls
46 lines (36 loc) · 932 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
37
38
39
40
41
42
43
44
45
46
public class Generation {
private Cell[] cells;
public Generation(CellState[] states) {
cells = new Cell[states.length];
for (int i = 0; i < cells.length; i++) {
cells[i] = new Cell(states[i]);
}
}
public Generation(String states) {
cells = new Cell[states.length()];
for (int i = 0; i < cells.length; i++) {
if (states.charAt(i) == 'O' || states.charAt(i) == '.') {
cells[i] = new Cell(CellState.getState(states.charAt(i)));
} else {
throw new IllegalArgumentException();
}
}
}
public Generation(Cell[] cells) {
this.cells = cells.clone();
//TODO figure this out
}
public int size() {
return cells.length;
}
public Cell getCell(int idx) {
return cells[idx];
}
public String toString() {
String concat = "";
for(int i = 0; i < cells.length; i++) {
concat = concat + cells[i].toString();
}
return concat;
}
}