Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- [currPos1-1]
- in
- (board[currPos1].contains("Ladder"))
- so I had to change it to
- (board[currPos1-1].contains("Ladder"))
- since the index of an array is starts from 0 not 1.
- I did that with the other if and else for player 2 as well.
- I also added this extra piece of code to allow the snake thing to work
- if(board[currPos1-1].contains("Ladder"))
- {
- currPos1 = ladder(currPos1);
- }
- else if (board[currPos1-1].contains("Snake"))
- {
- currPos1 = snake(currPos1);
- }
- exact same thing you were doing with the ladder but now you're checking if it contains a ladder
- Again added that to player 2 as well.
- 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.
- System.out.println("You landed on a ladder and your positin is"+currPos+".");
- return currPos;
- 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