ERace.java 699 Bytes
Newer Older
Ivaylo Ivanov's avatar
Ivaylo Ivanov committed
1 2 3 4 5 6
package at.ac.tuwien.sepm.assignment.individual.enums;

public enum ERace {
    ARABIAN,
    MORGAN,
    PAINT,
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
    APPALOOSA;

    public static boolean contains(String val) {
        // Loop through all values and check if the string is one of them
        // https://stackoverflow.com/a/9275694
        for(ERace race:values())
            if (race.name().equals(val))
                return true;
        return false;
    }

    public static String valuesToString() {
        String res = "";
        for(ERace race: values()) {
            res += race + ", ";
        }

        // Return the result without the last comma and space
        return res.substring(0, res.length() - 2);
    }
Ivaylo Ivanov's avatar
Ivaylo Ivanov committed
27
}