Skeleton Code

Before beginning, download and open the skeleton code from UTSOnline. This project contains a solution to Assignment 1 which must be used as a starting point for Assignment2.
The skeleton code project may be started by right-clicking on the UI class and selecting the main() method.
An alternative graphical user interface has also been provided for students who are curious to see how graphics could be added to the program. To run this, right-click on the GUI class and select its main() method. You are not required to make modifications to this class, and you are free to remove it from your project at any time.
Task 1: Rewrite the program to use arrays (40 marks)
It is important to complete the following tasks exactly as specified, and exactly in the same order. If you do not, PLATE will not be able to mark you. Be sure to submit your progress to PLATE regularly.
 1a) Replace the enemy1, enemy2 and enemy3 fields by a single array called enemies.
Throughout your Game, each time you refer to one of the fields enemy1, enemy2 or enemy3, replace that reference to the field by a reference to a particular position in the
enemies array. For example, whenever you refer to enemy1, you should refer to enemies[0] instead. In order to avoid a NullPointerException, you must also create the enemies array in the constructor before you attempt to store enemies into it.
 1b) Notice that the Game constructor now reads the number of enemies from the user and stores this into a local variable numEnemies. Modify your constructor so that it no longer creates 3 enemies, but instead creates however enemies the user requested, according to the number that is stored in the local variable numEnemies.

Modify each of the following methods to take into account the true length of the enemies array, rather than assuming 3 enemies:
 1c) toString()
 1d) print()
 1e) moveEnemies()
 1f) movePlayer()
 1g) over()
Task 2: Add new features (50 marks)
The following tasks are of varying levels of difficulty. In some cases, you may decide to skip a task and move on to the next one, unless that task is marked as REQUIRED. Any task marked as required cannot be skipped, and PLATE will not continue marking the later tasks until that task is correctly implemented. Be sure to submit your progress to PLATE regularly.
 2a) If the user types ‘1’ after the “move:” prompt, this will cause all of the enemy ships to reverse direction.
 2b) If a gun fires when multiple enemies are lined up in front of the gun, only the enemy closest to the gun will be hit. Hint: The modify the fire() method in PlayerShip and Gun to take the entire array of enemies, rather than a single enemy.
 2c) If the user types ‘2’ after the “move:” prompt, all of the enemies in the array will be sorted so that the enemy with the smallest x position will be placed into enemies[0], the
next smallest will be placed into enemies[1], and so on. You must implement one of the sorting algorithms presented in the lectures.
 2d) (REQUIRED) If an enemy is destroyed, it is resurrected 3*numEnemies moves later with its initial life intact.
 2e) If a user inputs a velocity for an enemy greater than 1, or less than -1, the velocity will indicate how many positions the enemy will move in one step. Care is required when an enemy hits a boundary and turns in the opposite direction. For example, if an
enemy is at position 2 and it moves at velocity 4, it will end up at position 6. But if the enemy is at position 3 and it moves at velocity 4, it will end up at position 5, because it would have hit the boundary and turned around before being able to move a total distance of 4 positions. After it has turned around, it’s velocity would change to -4 to indicate that it was moving left. For further clarification, submit your project to PLATE to see the expected output.
 2e) If the user types ‘3’ after the “move:” prompt, whichever enemy is directly in front of the player will be moved back to the farthest row of enemies, and every enemy that was behind it will be moved forward one row. For example, if there are 5 enemies e1,e2,e3,e4,e5 and enemy e3 is directly in front of the player when ‘2’ is pressed, the result will be e1,e2,e4,e5,e3.