chessai
college code for ai playing chess in java
git clone https://9o.is/git/chessai.git
commit 52bd0b918716539002c91b99d0d8d6980adac0d9 parent 67de6588727054163184eb4de4430fe4697f7e60 Author: Jul <jul@9o.is> Date: Mon, 3 Dec 2012 04:42:37 -0500 Added find method in ChessType class. Diffstat:
| M | src/chess/ChessType.java | | | 16 | ++++++++++++++++ |
1 file changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/chess/ChessType.java b/src/chess/ChessType.java @@ -1,5 +1,9 @@ package chess; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + /** * Check */ @@ -27,4 +31,16 @@ public enum ChessType { public String toString() { return symbol; } + + public static ChessType find(String symbol) { + for (ChessType type : VALUES) + if(type.toString().equals(symbol.toUpperCase())) + return type; + + return ChessType.NA; + } + + /* Cached list of all possible values. */ + private static final List<ChessType> VALUES = + Collections.unmodifiableList(Arrays.asList(values())); }