Tic Tac Toe/Connect 4 combined

0 Mayur Pande · June 24, 2015
Hi, I am creating enhancing my old tic tac toe game from a set 3*3 grid to allow the user to input their desired choice, I have put a limit to 6*6 currently as I want get my code working first. I also have set the number markers in a row to win to 4.

I am currently having trouble with my checkWin() method. I have currently not programmed the diagonal winning methods as of yet. I am still tinkering around with the checkRow() and checkCol() methods first. I iterate over the whole multidimensional array, and increment a count value each time a marker is placed in a row or a column along with a marker of the same type that has been placed there, and then return this value as true if there are four markers in a row or column together. If there are 4 in a row or column it works and says which player has won. However sometimes, if when playing it just prints out 'x' or 'o' have won which is not the case. Can anyone shed some light on what I am doing wrong. I have a feeling it is to do with the checkRow() and checkCol() methods, but cannot see where I have gone wrong.


public static boolean checkWin(){
return (checkRows()||checkCols());
private static boolean checkCols(){
int count = 0;

for(int i = 0; i < boardSize-1; i++){
for(int j = 0; j

Post a Reply


Oldest  Newest  Rating
0 Mayur Pande · June 24, 2015
Can anyone tell me why my full code that I have put is not showing up? Thanks
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator