Last active
December 16, 2015 01:09
-
-
Save andrefreitas/5353121 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean areAdjacent(int oldX, int oldY, int newX,int newY){ | |
int deltaX=newX-oldX; | |
int deltaY=newY-oldY; | |
if(deltaY==0 && deltaX!=0){ | |
for(int i=oldX+deltaX; i<7; i=i+deltaX){ | |
if(board.getAt(newY, i)!=board.INVALID_POSITION){ | |
if(i==newX) | |
return true; | |
else | |
return false; | |
} | |
} | |
} | |
else if(deltaX==0 && deltaY!=0){ | |
for(int i=oldY+deltaY; i<7; i=i+deltaY){ | |
System.out.println(newX+","+i); | |
if(board.getAt(newX, i)!=board.INVALID_POSITION){ | |
if(i==newY) | |
return true; | |
else | |
return false; | |
} | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment