For your first program, you are to write a simple Dodgeball simulation. In this simulation, we will have n players, and one ball. One player, the "thrower," will have the ball. The thrower will throw the ball at another player, the "target." The target could catch the ball, could be hit by the ball, or the ball could completely miss the target. If the target catches the ball, then the thrower is out of the game (and the target becomes the next thrower.) If the ball hits the target, then the target is out of the game. If the ball misses the target, neither player is out. In the latter two cases, any one can pick up the ball and become the next thrower. The game is over when only one player is left. In this simple version, the players (initially n players) will stand in a circle. The thrower will always count the players to his/her right, and then throw the ball at the dth player, who becomes the target. The target will always catch the ball, so that the thrower will be out of the game (and will leave the circle.) The other players remain at their positions in the circle. The new thrower then counts the players to his/her right, and throws the ball to the dth person, who catches it. The game continues until one player is left. Note that when the thrower counts to the dth player, the thrower may have to go around the circle (possibly more than once) and never counts himself/herself, to get to d. For example, if n is 3, that is, there are 3 players (say 1, 2, and 3) left, d is 5, and player 1 is the thrower, then player 1 will count the players 2, 3, 2, 3, 2 to get to 5, and then throw the ball at player 2. If there are only two players left, the thrower will always throw the ball at the other player. Program specifications The program will prompt the user to type in the number of players and then read in n. The program will prompt the user to type in the number of players to count to find the target, and then read in d. Input should be read from standard input (System.in). The initial players are numbered from 1 to n and form a circle. Player 1 is always the first thrower. The program will then simulate each round of the game. The program will print out the players at the start of the game and print out the players remaining after each turn. The circle of players should be printed out all on one line, the the assumption being that the first person follows the last person in the circle. The thrower should be indicated by an asterisk. The game stops when only one player is left. Output should be printed to standard output (System.out). For this assignment, you must use arrays not arraylists
For your first program, you are to write a simple Dodgeball simulation. In this simulation, we will have n
players, and one ball. One player, the "thrower," will have the ball. The thrower will throw the ball at another
player, the "target." The target could catch the ball, could be hit by the ball, or the ball could completely miss
the target. If the target catches the ball, then the thrower is out of the game (and the target becomes the next
thrower.) If the ball hits the target, then the target is out of the game. If the ball misses the target, neither
player is out. In the latter two cases, any one can pick up the ball and become the next thrower. The game is
over when only one player is left.
In this simple version, the players (initially n players) will stand in a circle. The thrower will always count
the players to his/her right, and then throw the ball at the dth player, who becomes the target. The target will
always catch the ball, so that the thrower will be out of the game (and will leave the circle.) The other players
remain at their positions in the circle. The new thrower then counts the players to his/her right, and throws
the ball to the dth person, who catches it. The game continues until one player is left. Note that when the
thrower counts to the dth player, the thrower may have to go around the circle (possibly more than once) and
never counts himself/herself, to get to d. For example, if n is 3, that is, there are 3 players (say 1, 2, and 3)
left, d is 5, and player 1 is the thrower, then player 1 will count the players 2, 3, 2, 3, 2 to get to 5, and then
throw the ball at player 2. If there are only two players left, the thrower will always throw the ball at the other
player.
Program specifications
The program will prompt the user to type in the number of players and then read in n. The program will
prompt the user to type in the number of players to count to find the target, and then read in d. Input should
be read from standard input (System.in). The initial players are numbered from 1 to n and form a circle.
Player 1 is always the first thrower. The program will then simulate each round of the game. The program
will print out the players at the start of the game and print out the players remaining after each turn. The
circle of players should be printed out all on one line, the the assumption being that the first person follows
the last person in the circle. The thrower should be indicated by an asterisk. The game stops when only one
player is left. Output should be printed to standard output (System.out). For this assignment, you must use arrays not arraylists
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images