icfp-model/src/main/java/ru/bosony/model/moving/Movement.java
branchindvdum
changeset 7 251961e44b5f
child 29 66aa96e8fd92
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/icfp-model/src/main/java/ru/bosony/model/moving/Movement.java	Sat Jul 14 02:07:51 2012 +0400
     1.3 @@ -0,0 +1,38 @@
     1.4 +package ru.bosony.model.moving;
     1.5 +
     1.6 +import ru.bosony.model.io.TextRepresentable;
     1.7 +
     1.8 +/**
     1.9 + * @author indvdum (gotoindvdum[at]gmail[dot]com) <br>
    1.10 + *         14.07.2012 0:40:35
    1.11 + * 
    1.12 + */
    1.13 +public enum Movement implements TextRepresentable {
    1.14 +	
    1.15 +	LEFT("L"),
    1.16 +	RIGHT("R"),
    1.17 +	UP("U"),
    1.18 +	DOWN("D"),
    1.19 +	WAIT("W"),
    1.20 +	ABORT("A");
    1.21 +
    1.22 +	private String	text;
    1.23 +
    1.24 +	private Movement(String text) {
    1.25 +		this.text = text;
    1.26 +	}
    1.27 +
    1.28 +	@Override
    1.29 +	public String toText() {
    1.30 +		return text;
    1.31 +	}
    1.32 +
    1.33 +	public static Movement fromText(String text) {
    1.34 +		for (Movement content : values()) {
    1.35 +			if (text != null && text.equals(content.toText()))
    1.36 +				return content;
    1.37 +		}
    1.38 +		return null;
    1.39 +	}
    1.40 +
    1.41 +}