public String checkVertical (Field field){
Point point1 = new Point(); //object creation figures
Point point2 = new Point(); //object creation figures
Point point3 = new Point(); //object creation figures
String x = null; //variable which will return for a final check of the winner
for (int i = 0; i < field.getSize(); i++){
//check the coordinates
point1.x = i;
point2.x = i;
point3.x = i;
point1.y = 0;
point2.y = 1;
point3.y = 2;
x = checkThreePoint(point1, point2, point3, field) ; // this method checks the figures on the coincidence(if there is 3 of 3 the winner is returned, otherwise null
if (x != null) {
return x; //this check stops the loop that is incorrect
}
else{
return null;
}
}
return x; // here should return the final winner
}
else { return null;}
Find more questions by tags Java