icfp-model/src/main/java/ru/bosony/model/moving/Movement.java
author indvdum (gotoindvdum[at]gmail[dot]com)
Sat, 14 Jul 2012 02:07:51 +0400
branchindvdum
changeset 7 251961e44b5f
child 29 66aa96e8fd92
permissions -rw-r--r--
Movements and Coordinates
     1 package ru.bosony.model.moving;
     2 
     3 import ru.bosony.model.io.TextRepresentable;
     4 
     5 /**
     6  * @author indvdum (gotoindvdum[at]gmail[dot]com) <br>
     7  *         14.07.2012 0:40:35
     8  * 
     9  */
    10 public enum Movement implements TextRepresentable {
    11 	
    12 	LEFT("L"),
    13 	RIGHT("R"),
    14 	UP("U"),
    15 	DOWN("D"),
    16 	WAIT("W"),
    17 	ABORT("A");
    18 
    19 	private String	text;
    20 
    21 	private Movement(String text) {
    22 		this.text = text;
    23 	}
    24 
    25 	@Override
    26 	public String toText() {
    27 		return text;
    28 	}
    29 
    30 	public static Movement fromText(String text) {
    31 		for (Movement content : values()) {
    32 			if (text != null && text.equals(content.toText()))
    33 				return content;
    34 		}
    35 		return null;
    36 	}
    37 
    38 }