Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Instruction for the given code: First, we need to make an objective for the game

ID: 644693 • Letter: I

Question

Instruction for the given code: First, we need to make an objective for the game. In the real game, numbers appear in random locations. The first player to occupy the square in which a number appears gets the points specified by the number. The following steps will add this feature:

1)In the game class, add data fields that will hold the position of the number square and its value. The value should start at 1 and increment every time a caterpillar catches it.

2)Modify the paint method in CaterpillarGame to display the number square, as well as the two caterpillars.

3)Create a method newNumberSquare to create a new, randomly distributed number value. Use the inPosition method provided by the two caterpillars to ensure that the number is not placed in a square already occupied by a caterpillar.

Add a score data field to each caterpillar, to hold its current score. As part of advancing to a new position, have the caterpillar test the new position to see whether it is a scoring position. This can be most easily accomplished by adding a method squareScore to the class CaterpillarGame. This method will take as argument the new position offered by caterpillar. If the new position is not a scoring position, it will return zero. If it is a scoring position, it will return the score and call newNumberSquare to create a new scoring position.

Add labels to the game window to display the two caterpillar scores.

The two-player game now has scores but no simple way to end.

In the original game, each caterpillar segment has a lifetime. This can be simulated by having each caterpillar maintain a counter

Explanation / Answer

The numbers can be arranged in such a way that, if the caterpillar skips then it will lose 1 point and color will be changed. If it catches two squares at a time then bonus poit will benifited. Drones can be added as an obstacle for the caterpillar.