if I wanted to create a method named cannotMove, by using if atWorldEdge and canSee(crab.class). How would I go about this so that cannotMove returns true when one or the other is invoked?


1 2 3 4 | public boolean cannotMove() { return (atWorldEdge() || canSee(crab. class )); } |
1 2 3 4 5 6 7 8 9 10 | private void changeDirection() { turnLeft(); // now facing left if (!cannotMove) return ; turnBack(); // turning from facing left to facing right if (!cannotMove) return ; turnRight(); // turning from facing right to facing back if (!cannotMove) return ; turn( 17 ); } |