Why is my Point array only returning null in Java? -
i'm trying write method uses board , check see if @ given point on board, swap between 1 point right or below, causes "match" occur on board. points cause swap added point[] , returned. array returns, returns, [null],[null],[null]. why not returning points?
thanks
public static point[] findpossibleswaps(board b) { point[] swaps = new point[3]; int x = 0; int y = 0; point normal = new point (x,y); point hor = new point (x+1, y); point ver = new point (x, y+1); int count = 0; for(y = 0; y < b.getsize()-1; y++) { for(x = 0; x < b.getsize()-1; x++) { b.swapsquares(normal,hor); if (b.hasmatches() && (x)!=b.getsize()-1) { swaps[count] = new point(x+1,y); count++; } b.swapsquares(hor, normal); b.swapsquares(normal, ver); if (b.hasmatches() && y!=b.getsize()-1) { swaps[count] = new point(x,y+1); count++; } b.swapsquares(ver, normal); } } return swaps; }
Comments
Post a Comment