Hi!
It says the getShipCount() method is missing in the EnemyFleet class. But it's there...
Any idea?
Thank you!
The game is lost not only if the player's ship is destroyed, but also if the enemy fleet reaches the player's ship.
To determine the coordinates of the lower edge of the enemy fleet, we'll add a getBottomBorder() method.
If all the enemies are destroyed, the player wins. For convenience, we'll add a getShipCount(), method that will return the number of ships remaining in the enemy fleet.
If the number is 0, you need to call the stopGameWithDelay() method and call the win() method on the playerShip object. This method replaces the player's ship matrix with ShapeMatrix.WIN_PLAYER.
We'll check the number of ships remaining in the enemy fleet and whether they have reached the player's ship in the check() method.
Requirements:
- The EnemyFleet class must have a public double getBottomBorder() method.
- The getBottomBorder() method must return the largest (y + height) value of all of the enemy ships in the ships list.
- The EnemyFleet class must have a public int getShipCount() method.
- The getShipCount() method must return the number of enemy ships in the ships list.
- The PlayerShip class must have a public void win() method.
- The PlayerShip class's win() method must call the setStaticView(int[][]) method. Pass ShapeMatrix.WIN_PLAYER as the argument.
- In the SpaceInvadersGame class's check() method, you need to call the getBottomBorder() method on the enemyFleet object.
- If the value returned by the getBottomBorder() method is greater than or equal to playerShip.y, the check() method must call the kill() method on the playerShip object.
- In the SpaceInvadersGame class's check() method, you need to call the getShipCount() method on the enemyFleet object.
- If the value returned by the getShipCount() method is 0, the check() method must call the win() method on the playerShip object and call the SpaceInvadersGame class's stopGameWithDelay() method.
package com.codegym.games.spaceinvaders;
public enum Direction {
RIGHT, LEFT, UP, DOWN;
}