equal
deleted
inserted
replaced
5 /** |
5 /** |
6 * @author indvdum (gotoindvdum[at]gmail[dot]com) <br> |
6 * @author indvdum (gotoindvdum[at]gmail[dot]com) <br> |
7 * 13.07.2012 21:25:49 |
7 * 13.07.2012 21:25:49 |
8 * |
8 * |
9 */ |
9 */ |
10 public abstract class CellContent implements TextRepresentable { |
10 public enum CellContent implements TextRepresentable { |
|
11 |
|
12 ClosedLambdaLift("L"), |
|
13 Earth("."), |
|
14 Empty(" "), |
|
15 Lambda("\\"), |
|
16 MiningRobot("R"), |
|
17 OpenLambdaLift("O"), |
|
18 Rock("*"), |
|
19 Wall("#"); |
|
20 |
|
21 private String text; |
|
22 |
|
23 private CellContent(String text) { |
|
24 this.text = text; |
|
25 } |
11 |
26 |
12 @Override |
27 @Override |
13 public CellContent fromText(String text) { |
28 public String toText() { |
14 for (CellContent content : new CellContent[] { |
29 return text; |
15 new ClosedLambdaLift(), |
30 } |
16 new Earth(), |
31 |
17 new Empty(), |
32 public static CellContent fromText(String text) { |
18 new Lambda(), |
33 for (CellContent content : values()) { |
19 new MiningRobot(), |
|
20 new OpenLambdaLift(), |
|
21 new Rock(), |
|
22 new Wall() |
|
23 }) { |
|
24 if (text != null && text.equals(content.toText())) |
34 if (text != null && text.equals(content.toText())) |
25 return content; |
35 return content; |
26 } |
36 } |
27 return null; |
37 return null; |
28 } |
38 } |