Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean Safe ( int r, int c, String word, int rowIncrement, int colIncrement){
- if (rowIncrement == 0 && colIncrement == 0) {
- return false;
- }
- int x = c;
- int y = r;
- for (int i = 0; i < word.length(); i++) {
- char letter = word.charAt(i);
- if (x > c || x < 0 || y > r || y < 0){
- return false;
- }
- if (data[x][y] != letter) {
- if (data[x][y] != '_'){
- return false;
- }
- }
- x = x + colIncrement;
- y = y + rowIncrement;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement