Task a) is a Generics task. Task b) and beyond are keeping task, as described below.
You should make a game with 10x10. The board starts with the player (¤) in one corner and an enemy (*) a random place in the fourth part of the game board that is farthest from the player. It should also be placed 5 goodies (o) randomly on the game board. The goal is to eat up all the goodies without getting eaten by the enemy. You eat up a treat by going on top of it. You can go the route of time, up or down, left or right, but not diagonally.
The enemy should be in a separate thread move around randomly on the board. The enemy moves in the same way as the player. First, wait for one second between each time it moves and then shall it be less and less time until it uses 100 milliseconds.
If you manage to eat up all the goodies to the game go to the next round. For each new round is an additional enemy, and each new enemy is 100 milliseconds faster to move than the last.
The aim of the game is to clear as many rounds as possible.
a) Create a generic method that takes in two collections of compatible types and returns a collection that contains only items that are included in both. The returned collection will have a type parameter that covers both collections being submitted. Use equals method to check the similarity between objects. (Note: you need not worry about performance and may well use a double for loop to test for items that are included in both)
b) Create a 10x10 grid of buttons that are disabled. You can disable one JButton to call setEnabled (false) on it.
c) Make a player, an Action Listener for buttons and make it so only the buttons around the player is enabled. The buttons move the player to the route where the button is.
d) Create 5 goodies scattered around the board randomly. The aim of the game is to collect all the goodies. Once the player has made it's next round.
e) In the first round there is one enemy. The enemy is a separate thread. It starts to move every second (1000 milliseconds). It will move a random direction. For each move is the time for the next move down to 5 milliseconds (ie: it moves faster and faster). If the enemy moves into the player or the player moving into an enemy, the player has lost. The enemy will start at a random position in the quadrant of the board farthest from the player. If the player starts on schedule [url removed, login to view], the enemy will start in a random route with x and y coordinates between 1 and 5
f) For each round there will be an additional enemy. Each additional enemy starts to move 100 milliseconds faster than the last enemy (as in round 3 there are 3 enemies. They start to move after 1000, 900 and 800 milliseconds. Every enemy move 5 milliseconds faster for each move).