Essay On Java

1278 Words6 Pages
/** * Connect Four allows you to play Concect Four * @author Andrew Seitzman */ import java.util.Scanner; public class ConnectFour { /** * The getColumn method lets you type in a column number you want your piece to fall in * @message allows you to prompt the user when the method is called * @return the return value is the row or column the user chose */ public static int getColumn(String message) { Scanner scan = new Scanner(System.in); System.out.println(message); return scan.nextInt()-1; }

/** * The getRowCount method gets what row to fill based on how full every row is already * @param row is the row being filled * @param column is the column being filled
…show more content…
be returned to end the game * @return the return value should end the game */ public static int diagonalUpperLeftToLowerRightYellowWinner(String [][] board, int turnLimit){ int startRow; int startColumn; for (startRow = 0; startRow < 3; startRow++){ for (startColumn = 0; startColumn < 4; startColumn++){ String check = board[startRow][startColumn]; if (check.equals("Y") && check.equals(board[startRow+1][startColumn+1]) && check.equals(board[startRow+2][startColumn+2]) && check.equals(board[startRow+3][startColumn+3])){ System.out.println("Yellow Wins!"); turnLimit=100; } } } return turnLimit; }

/** * The diagonalUpperLeftToLowerRightRedWinner method checks for wins from the upper left to the lower right for red * @param [][] board is the game board * @param turnLimit is supposed to be returned to end the game * @return the return value should end the game */ public static int diagonalUpperLeftToLowerRightRedWinner(String [][] board, int turnLimit){ int startRow; int startColumn; for (startRow = 0; startRow < 3; startRow++){ for (startColumn = 0; startColumn < 4; startColumn++){ String check = board[startRow][startColumn]; if (check.equals("R") && check.equals(board[startRow+1][startColumn+1]) &&

More about Essay On Java

Get Access