Format code

This commit is contained in:
Victor 2014-01-17 18:47:48 +02:00
parent c70ec31da6
commit bfb89267b7
6 changed files with 243 additions and 246 deletions

View File

@ -13,6 +13,7 @@ import javax.swing.JPanel;
* @author aNNiMON
*/
public class GameBoard extends JPanel {
private static final int CELL_SIZE = 150;
private static final int OFFSET = 15;

View File

@ -11,7 +11,6 @@ public class Main extends JFrame {
public static void main(String[] args) {
new Main().setVisible(true);
}
public Main() {

View File

@ -44,7 +44,7 @@ public class Table {
}
public void setFigure(int x, int y) {
if( (checkWinner() != Figure.EMPTY) || (!hasMoreMoves()) ) {
if ( (checkWinner() != Figure.EMPTY) || (!hasMoreMoves()) ) {
resetTable();
return;
}
@ -59,7 +59,7 @@ public class Table {
}
public void computerMove() {
if( (checkWinner() != Figure.EMPTY) || (!hasMoreMoves()) ) {
if ( (checkWinner() != Figure.EMPTY) || (!hasMoreMoves()) ) {
//resetTable();
return;
}
@ -105,14 +105,14 @@ public class Table {
// Trying to put figure to the center.
int x = 1, y = 1;
if(!table[y][x].isEmpty() || (random.nextInt(5) <= 3) ) {
if (!table[y][x].isEmpty() || (random.nextInt(5) <= 3) ) {
// If it's busy, put to the corners.
int count = 0;
do {
x = random.nextBoolean() ? 0 : 2;
y = random.nextBoolean() ? 0 : 2;
count++;
} while ( (!table[y][x].isEmpty()) && (count < 10));
} while ( (!table[y][x].isEmpty()) && (count < 10) );
if (count > 9) {
// Put to the remaining cells.
@ -122,7 +122,7 @@ public class Table {
x = pair[random.nextInt(pair.length)][0];
y = pair[random.nextInt(pair.length)][1];
count++;
} while ( (!table[y][x].isEmpty()) && (count < 10));
} while ( (!table[y][x].isEmpty()) && (count < 10) );
}
}
table[y][x].setFigure(nextMoveIsX ? Figure.X : Figure.O);

View File

@ -103,7 +103,6 @@ public class TitlePanel extends JPanel {
});
setLayout(null);
final JButton exitButton = new JButton();
exitButton.setIcon(new ImageIcon(exitImageBW));
exitButton.setBorder(null);
@ -177,5 +176,4 @@ public class TitlePanel extends JPanel {
mainFrame.setLocation(moved);
}
}
}

View File

@ -21,5 +21,4 @@ public class Util {
}
return image;
}
}