icfp-model/src/main/java/ru/bosony/model/moving/Movement.java
branchindvdum
changeset 7 251961e44b5f
child 29 66aa96e8fd92
equal deleted inserted replaced
6:0dbbc8983926 7:251961e44b5f
       
     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 }