home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jsamples.z / MoveTuple.java < prev    next >
Encoding:
Java Source  |  1997-07-03  |  1.2 KB  |  43 lines

  1. package borland.samples.apps.chess.client.board;
  2.  
  3. public class MoveTuple
  4. {
  5.   public int newpieceValue;
  6.   public int pieceValue;
  7.   public int pieceColor;
  8.   public int fromRank;
  9.   public int fromFile;
  10.   public int toRank;
  11.   public int toFile;
  12.  
  13.   public MoveTuple() {
  14.     newpieceValue = 0;
  15.     pieceValue    = 0;
  16.     pieceColor    = 0;
  17.     fromRank      = 0;
  18.     fromFile      = 0;
  19.     toRank        = 0;
  20.     toFile        = 0;
  21.   }
  22.  
  23.   public MoveTuple(String x) {
  24.     try {
  25.       newpieceValue = Integer.parseInt(x.substring(6));
  26.       pieceValue    = Integer.parseInt(x.substring(0,1));
  27.       pieceColor    = Integer.parseInt(x.substring(1,2));
  28.       fromRank      = Integer.parseInt(x.substring(2,3));
  29.       fromFile      = Integer.parseInt(x.substring(3,4));
  30.       toRank        = Integer.parseInt(x.substring(4,5));
  31.       toFile        = Integer.parseInt(x.substring(5,6));
  32.     }
  33.     catch (Exception e) {
  34.       System.out.println("Failed to parse tokenmsg " + e);
  35.     }
  36.   }
  37.  
  38.   public String toString() {
  39.     //override this java.lang.Object method
  40.     return String.valueOf(pieceValue) + pieceColor + fromRank + fromFile + toRank + toFile + newpieceValue;
  41.   }
  42. }
  43.