org/homelinux/largo/games/board/Board.java
changeset 15 d4b2b9a87d80
parent 14 f12f77aa13b2
child 16 55b0d5006e7b
--- a/org/homelinux/largo/games/board/Board.java
+++ b/org/homelinux/largo/games/board/Board.java
@@ -9,7 +9,7 @@
 import java.awt.Dimension;
 import java.awt.Graphics;
 import java.awt.Image;
-import java.util.Vector;
+import java.util.ArrayList;
 
 import javax.swing.JPanel;
 
@@ -21,7 +21,7 @@
     protected Piece board_pieces[];
     private Piece pieces[];
 
-    protected Vector<History> stack;
+    protected ArrayList<History> stack;
     protected int moveNr;
 
     protected static final int EMPTY = 0;
@@ -56,7 +56,7 @@
         black = false;
         blacksTurn = false;
         board_pieces = getPieces(pieces);
-        stack = new Vector<History>();
+        stack = new ArrayList<History>();
         moveNr = 0;
     }
 
@@ -286,8 +286,8 @@
 
         moveNr -= 2;
 
-        h1 = stack.elementAt(moveNr);
-        h2 = stack.elementAt(moveNr + 1);
+        h1 = stack.get(moveNr);
+        h2 = stack.get(moveNr + 1);
 
         board_pieces[h1.pos] = h1.piece;
         board_pieces[h2.pos] = h2.piece;
@@ -305,8 +305,8 @@
         if (moveNr > stack.size() - 2)
             return;
 
-        h1 = stack.elementAt(moveNr);
-        h2 = stack.elementAt(moveNr + 1);
+        h1 = stack.get(moveNr);
+        h2 = stack.get(moveNr + 1);
 
         board_pieces[h1.pos] = h2.piece;
         board_pieces[h2.pos] = new Piece(null, null, EMPTY, 0);
@@ -334,14 +334,12 @@
         if (size < 2)
             return;
 
-        h1 = stack.elementAt(size - 1);
-        h2 = stack.elementAt(size - 2);
+        h1 = stack.remove(size - 1);
+        h2 = stack.remove(size - 2);
 
         pieces[h1.pos] = h1.piece;
         pieces[h2.pos] = h2.piece;
 
-        stack.setSize(size - 2);
-
         /* Reset the current player */
         setBlacksTurn(h2.turn);
     }