int check() { int start_p = 0, start_d = 0, end_p = 0, end_d = 0; int[] start_count = startLand.getObjNum(); start_p += start_count[0]; start_d += start_count[1]; int[] end_count = endLand.getObjNum(); end_p += end_count[0]; end_d += end_count[1]; if (end_p + end_d == 6) { return(2); } int[] boatCount = boat.getObjNum(); if (boat.getState() == -1) //to { end_p += boatCount[0]; end_d += boatCount[1]; } if (boat.getState() == 1) //from { start_p += boatCount[0]; start_d += boatCount[1]; } if (start_p < start_d && start_p > 0) { return(1); } if (end_p < end_d && end_p > 0) { return(1); } return(0); }