equal
deleted
inserted
replaced
1 package ru.bosony.model.cellscontents; |
1 package ru.bosony.model.cellscontents; |
|
2 |
|
3 import java.util.HashSet; |
|
4 import java.util.Set; |
2 |
5 |
3 import ru.bosony.model.io.TextRepresentable; |
6 import ru.bosony.model.io.TextRepresentable; |
4 |
7 |
5 /** |
8 /** |
6 * @author indvdum (gotoindvdum[at]gmail[dot]com) <br> |
9 * @author indvdum (gotoindvdum[at]gmail[dot]com) <br> |
7 * 13.07.2012 21:25:49 |
10 * 13.07.2012 21:25:49 |
8 * |
11 * |
9 */ |
12 */ |
10 public enum CellContent implements TextRepresentable { |
13 public enum CellContent implements TextRepresentable { |
11 |
14 |
12 ClosedLambdaLift("L"), |
15 ClosedLambdaLift("L"), |
13 Earth("."), |
16 Earth("."), |
14 Empty(" "), |
17 Empty(" "), |
15 Lambda("\\"), |
18 Lambda("\\"), |
16 MiningRobot("R"), |
19 MiningRobot("R"), |
17 OpenLambdaLift("O"), |
20 OpenLambdaLift("O"), |
18 Rock("*"), |
21 Rock("*"), |
19 Wall("#"); |
22 Wall("#"), |
|
23 TrampolineA("A"), |
|
24 TrampolineB("B"), |
|
25 TrampolineC("C"), |
|
26 TrampolineD("D"), |
|
27 TrampolineE("E"), |
|
28 TrampolineF("F"), |
|
29 TrampolineG("G"), |
|
30 TrampolineH("H"), |
|
31 TrampolineI("I"), |
|
32 Target1("1"), |
|
33 Target2("2"), |
|
34 Target3("3"), |
|
35 Target4("4"), |
|
36 Target5("5"), |
|
37 Target6("6"), |
|
38 Target7("7"), |
|
39 Target8("8"), |
|
40 Target9("9"); |
20 |
41 |
21 private String text; |
42 private String text; |
|
43 private CellContent trampolineTarget = null; |
|
44 private static Set<CellContent> trampolines = new HashSet<CellContent>(); |
|
45 private static Set<CellContent> targets = new HashSet<CellContent>(); |
|
46 static { |
|
47 trampolines.add(TrampolineA); |
|
48 trampolines.add(TrampolineB); |
|
49 trampolines.add(TrampolineC); |
|
50 trampolines.add(TrampolineD); |
|
51 trampolines.add(TrampolineE); |
|
52 trampolines.add(TrampolineF); |
|
53 trampolines.add(TrampolineG); |
|
54 trampolines.add(TrampolineH); |
|
55 trampolines.add(TrampolineI); |
|
56 targets.add(Target1); |
|
57 targets.add(Target2); |
|
58 targets.add(Target3); |
|
59 targets.add(Target4); |
|
60 targets.add(Target5); |
|
61 targets.add(Target6); |
|
62 targets.add(Target7); |
|
63 targets.add(Target8); |
|
64 targets.add(Target9); |
|
65 } |
22 |
66 |
23 private CellContent(String text) { |
67 private CellContent(String text) { |
24 this.text = text; |
68 this.text = text; |
25 } |
69 } |
26 |
70 |
35 return content; |
79 return content; |
36 } |
80 } |
37 return null; |
81 return null; |
38 } |
82 } |
39 |
83 |
|
84 public CellContent getTrampolineTarget() { |
|
85 return trampolineTarget; |
|
86 } |
|
87 |
|
88 public void setTrampolineTarget(CellContent trampolineTarget) { |
|
89 if (!trampolines.contains(this) || trampolineTarget != null && !targets.contains(trampolineTarget)) |
|
90 throw new RuntimeException("Only references from Trampolines to Targets allowed"); |
|
91 this.trampolineTarget = trampolineTarget; |
|
92 } |
|
93 |
|
94 public static Set<CellContent> getTrampolines() { |
|
95 return trampolines; |
|
96 } |
|
97 |
|
98 public static Set<CellContent> getTargets() { |
|
99 return targets; |
|
100 } |
|
101 |
40 } |
102 } |