Land.java

package robot;


public enum Land {

    Earth(1),
    Rock(2),
    Sand(4),
    Mud(3),
    Unusable(0);

    public final int coefficient;

    Land(int coefficient) {
        this.coefficient = coefficient;
    }

    public static Land getLandByOrdinal(int ordinal) throws TerrainNonRepertorieException {
        for (Land land : Land.values()) {
            if (land.ordinal()==ordinal) return land;
        }
        throw new TerrainNonRepertorieException();
    }

    public static int countLand() {
        return Land.values().length;
    }
}