/** * This util method will be used to return an instance of Face for the specified value. * * <p>A null will be return if the specified input is not a valid face value. * * @param value * @return */ public static Face getFace(String value) { for (Face face : Face.values()) { // ignore case if (face.getSymbol().equalsIgnoreCase(value)) { return face; } } return null; }
static { for (Suit suit : Suit.values()) for (Face face : Face.values()) theDeck.add(new Card(face, suit)); }
/** * Returns a Face according to the specified ID * * @param id id of face * @return face */ public static Face fromId(final int id) { for (Face e : Face.values()) if (e.id == id) return e; return null; }