Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. public boolean Safe ( int r, int c, String word, int rowIncrement, int colIncrement){
  2. if (rowIncrement == 0 && colIncrement == 0) {
  3. return false;
  4. }
  5. int x = c;
  6. int y = r;
  7. for (int i = 0; i < word.length(); i++) {
  8. char letter = word.charAt(i);
  9. if (x > c || x < 0 || y > r || y < 0){
  10. return false;
  11. }
  12. if (data[x][y] != letter) {
  13. if (data[x][y] != '_'){
  14. return false;
  15. }
  16. }
  17. x = x + colIncrement;
  18. y = y + rowIncrement;
  19. }
  20. return true;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement