Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1.  
  2. public void face(Direction dir) {
  3. for (int i = 0; i < 3; i++) {
  4. if(facingWest() && dir == Directions.West) return;
  5. if(facingNorth() && dir == Directions.North) return;
  6. if(facingSouth() && dir == Directions.South) return;
  7. if(facingEast() && dir == Directions.East) return;
  8. turnLeft();
  9. }
  10. }
  11.  
  12. public void move(int spaces, Direction dir) {
  13. face(dir);
  14. for (int i = 0; i < spaces; i++) {
  15. move();
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement