Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool invalidMove(int row, int col, char direction) {
- bool invalidLine = true;
- if (!(0<=row && row <=2 )) {
- return true;
- }
- else if (!(0<=col && col <=2 )) {
- return true;
- }
- else if ((direction != 'u') && (direction != 'l') && (direction != 'd') && (direction != 'r')) {
- return true;
- }
- if (row == 0 && direction == 'u')
- return true;
- if (row == 2 && direction == 'd')
- return true;
- if (col == 0 && direction == 'l')
- return true;
- if (col == 2 && direction == 'r')
- return true;
- if (direction == 'u' || direction == 'd') {
- int linerow = row;
- if (direction == 'u')
- --linerow;
- if (grid.vertical(linerow, col) == true)
- invalidLine = false;
- }
- else if (direction == 'l' || direction == 'r') {
- int linecolumn = col;
- if (direction == 'l')
- --linecolumn;
- if(grid.horizontal(row,linecolumn) == true)
- invalidLine = false;
- return (!invalidLine);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement