Advertisement
Guest User

ConnectFour.java

a guest
Jan 8th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1. package siena;
  2.  
  3. public class ConnectFour {
  4.     public static boolean redsTurn = true;
  5.     public static int redCheck = 0;
  6.     public static int yellowCheck = 0;
  7.     public static boolean yellowWon = false;
  8.     public static boolean redWon = false;
  9.     public static int[][] slotStat;
  10.     public static CFBoard board;
  11.     public static void main (String[] args) throws java.lang.Exception {
  12.         board = new CFBoard();
  13.         board.setUp();
  14.         slotStat = new int[7][6];
  15.         for (int x = 0; x < 7; x++) {
  16.             for (int y = 0; y < 6; y++) {
  17.                 slotStat[x][y] = 0;
  18.             }
  19.         }
  20.         while (!redWon && !yellowWon);
  21.     }
  22.     public static void takeMove(int buttonPressed) {
  23.         switch(buttonPressed){
  24.         case 0:
  25.             for (int x = 0; x < 7; x++) {
  26.                 for (int y = 0; y < 6; y++) {
  27.                     slotStat[x][y] = 0;
  28.                 }
  29.                 board.doThing();
  30.                 redsTurn = true;
  31.             }
  32.             break;
  33.         case 1: case 2: case 3: case 4: case 5: case 6: case 7:
  34.             if (slotStat[buttonPressed - 1][0] != 0) {
  35.                 break;
  36.             }
  37.             for (int y = 0; y < 6; y++) {
  38.                 if (y == 5 || slotStat[buttonPressed - 1][y + 1] != 0) {
  39.                     if(redsTurn) {
  40.                         slotStat[buttonPressed - 1][y] = 1;
  41.                         if (redCheck > 4) checkWin(buttonPressed - 1, y);
  42.                     }
  43.                     else slotStat[buttonPressed - 1][y] = 2;
  44.                     break;
  45.                 }
  46.             }
  47.             redsTurn = !redsTurn;
  48.            
  49.             board.doThing();
  50.         }
  51.     }
  52.     private static void checkWin(int x, int y) {
  53.        
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement