Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. So all I did was move the thing where you were checking if the player one position had a ladder to right after the first user rolls their dice. It was dectecting the ladder cause you weren't doing
  2. [currPos1-1]
  3. in
  4. (board[currPos1].contains("Ladder"))
  5. so I had to change it to
  6. (board[currPos1-1].contains("Ladder"))
  7. since the index of an array is starts from 0 not 1.
  8.  
  9. I did that with the other if and else for player 2 as well.
  10.  
  11. I also added this extra piece of code to allow the snake thing to work
  12. if(board[currPos1-1].contains("Ladder"))
  13. {
  14. currPos1 = ladder(currPos1);
  15. }
  16. else if (board[currPos1-1].contains("Snake"))
  17. {
  18. currPos1 = snake(currPos1);
  19. }
  20. exact same thing you were doing with the ladder but now you're checking if it contains a ladder
  21.  
  22. Again added that to player 2 as well.
  23.  
  24. Here I removed the if statement in the ladder method you had at the end and just changed it to this, it wasn't needed.
  25. System.out.println("You landed on a ladder and your positin is"+currPos+".");
  26. return currPos;
  27.  
  28. All you need to do is just add a print that tells the user in the snake method that they landed on a snake and just clean up the prints.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement