1.1 --- a/icfp-model/src/main/java/ru/bosony/model/cellscontents/CellContent.java Fri Jul 13 21:55:14 2012 +0400
1.2 +++ b/icfp-model/src/main/java/ru/bosony/model/cellscontents/CellContent.java Sat Jul 14 00:36:43 2012 +0400
1.3 @@ -7,20 +7,30 @@
1.4 * 13.07.2012 21:25:49
1.5 *
1.6 */
1.7 -public abstract class CellContent implements TextRepresentable {
1.8 +public enum CellContent implements TextRepresentable {
1.9 +
1.10 + ClosedLambdaLift("L"),
1.11 + Earth("."),
1.12 + Empty(" "),
1.13 + Lambda("\\"),
1.14 + MiningRobot("R"),
1.15 + OpenLambdaLift("O"),
1.16 + Rock("*"),
1.17 + Wall("#");
1.18 +
1.19 + private String text;
1.20 +
1.21 + private CellContent(String text) {
1.22 + this.text = text;
1.23 + }
1.24
1.25 @Override
1.26 - public CellContent fromText(String text) {
1.27 - for (CellContent content : new CellContent[] {
1.28 - new ClosedLambdaLift(),
1.29 - new Earth(),
1.30 - new Empty(),
1.31 - new Lambda(),
1.32 - new MiningRobot(),
1.33 - new OpenLambdaLift(),
1.34 - new Rock(),
1.35 - new Wall()
1.36 - }) {
1.37 + public String toText() {
1.38 + return text;
1.39 + }
1.40 +
1.41 + public static CellContent fromText(String text) {
1.42 + for (CellContent content : values()) {
1.43 if (text != null && text.equals(content.toText()))
1.44 return content;
1.45 }