Question: Java code, no arraylists or hashmap or any kind of hashmap, nothing of that kind please, only scanner and random generator Part 1) In this

Java code, no arraylists or hashmap or any kind of hashmap, nothing of that kind please, only scanner and random generator Java code, no arraylists or hashmap or any kind of hashmap,nothing of that kind please, only scanner and random generator Part 1)In this part, you need to create a class called LadderAndSnake. A

Part 1) In this part, you need to create a class called LadderAndSnake. A LadderAndSnake object has a board of 10x10 and a number of players attached to it, which is initialized at the creation time of the object. The number of players must be between 2 and 4 inclusively. The number of players must be set through the use of a parameterized constructor of the class. In addition, the board itself is set as shown in Figure 1 below. 100 00 TO DAN 412 LLL Figure 1: Ladder and Snake Board Besides the constructors, and all basic methods in the class, the class must include two methods, one called flipDice(), which should return a random value between 1 and 6 inclusively. The other method is called play(), which actually initiate the core engine of the game where the players start to play the game. The rules of the game are as below: Before any of the players starts playing, the order of playing tums must be determined. For that, cach player must throw the dice to obtain the largest possible number. In case of a tie between any of the players, the process is repeated only between those players. This process is concluded once the order of playing is determined. At this point, the players start playing the game by alternating dice flipping. Each dice flip will move a player form square 0 (which you can think about it as outside the board) with the value of the dice. For example, if a player is at square and the dice value was 5, then the player moves to square 5. If the reached square has a bottom of a ladder, then the player moves up to the square that has the top of the ladder. For instance, if a player is at square 33, and the flipped dice value was 3, then the player moves to square 36, which in tum will end moving the player up to square 44. if the reached square has a head of a snake, then the player moves down the square that has the tail of the snake. For instance, if a player is at square 77, and the flipped dice value 2, then the player moves to square 79 (which has the tip of the snake's head), which in turn end moving the player down to square 19. You will have to find a way to record the relation between these particular ladder and snake squares. The game is concluded once any of the players EXACTLY, reaches square 100. If a player is close to 100, and the dice value exceeds the maximum possible moves, the player moves backward with the excessive amount. For instance, if a player is at square 96 and the dice value is 5, then the player moves to 99 (that is 4 moves to 100, then 1 move backward to 99). As a general requirement, you must show/display ALL operations of the game. For instance, at start, you should indicate something like: Game is played by x players (where x is the number of players set for that game); Now deciding which player will start playing, Player 1 got a dice value of 5 Player 2 got a dice value of 3 Player 3 got a dice value of 3 A tie was achieved between Player 2 and Player 3. Attempting to break the tie Player 2 got a dice value of 2 Player 3 got a dice value of 6 - Reached final decision on order of playing: Player 1, Player 3, Player 2 - Player 1 got a dice value of 5; now in square 5 Player 3 got a dice value of 6; now in square 6 Player 2 got a dice value of 4: gone to square 4 then up to square 14 Game not over, flipping again Player 1 got dice value of 4; gone to square 9 then up to square 31 Player 3 got dice value of 4; now in square 10 Player 2 got dice value of 2; gone to square 16 then down to square 6 Game not over; flipping again The above sample of displays is the basic minimum that you should have. A better mark is given for implementing the board as a 2-D array, and for a more elaborate/creative displays (i.c. possibly visibly showing the plays/moves, giving each of the players a name, etc. There is no limit of what you can do here. Be impressive!). Part II) Create a public driver class called PlayLadder AndSnake. In the main() method, you need to prompt the user to enter the number of players that he/she needs to play the game with. The user must enter a value between 2 and 4. If the user does not enter a correct value, the program must prompt the user again to enter a correct value. However, there is a limit of 4 total attempts. If the user enters an incorrect value 4 times, then the program must display a message to this effect and terminates. For instance, the program behaviour may look something similar to the following: Enter the # of players for your game - Number must be between 2 and 4 inclusively: Bad Attempt 1 - Invalid # of players. Please enter a fi between 2 and 4 inclusively: Bad Attempt 2 - Invalid # of players. Please enter a fi between 2 and 4 inclusively: i 5 Bad Attempt 3 - Invalid # of players. Please enter a il between 2 and 4 inclusively. This is your last attempt 10 Bad Attempt 4! You have exhausted all your chances. Program will terminate! 6 8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!