Package battleship.view
Interface View
- All Known Implementing Classes:
AbstractView,Terminal,Window
public interface View
View interface, used as an API
This model (interface -> abstract class(es) -> concrete classes) prevent hard code.
This is the only object which interact with other object
Allows an outside person easily change the code or add a view easily without modifying existing classes
- See Also:
AbstractView,Terminal,Window
-
Field Summary
Fields Modifier and Type Field Description static int[]shipsSize -
Method Summary
Modifier and Type Method Description Pair<java.lang.Integer,java.lang.Integer>chooseMove(Player player)ask the player the choose a position on its opponent gridvoiddisplayBoard()Display all gridsvoiddisplayWinner(Player winner)Display the winner of the game and then close the gamevoidsetShips(Player player)Askplayerto set position of its ships
-
Field Details
-
shipsSize
static final int[] shipsSize
-
-
Method Details
-
setShips
Askplayerto set position of its ships- Parameters:
player- player instance we ask- Throws:
java.lang.InterruptedException- seeWindow.setShips(Player)
-
displayBoard
void displayBoard()Display all grids -
chooseMove
Pair<java.lang.Integer,java.lang.Integer> chooseMove(Player player) throws java.lang.InterruptedExceptionask the player the choose a position on its opponent grid- Parameters:
player-Game.currentPlayer- Returns:
- a element containing the x and y coordinate (left side store Y and right side X)
- Throws:
java.lang.InterruptedException- seeWindow.chooseMove(Player)
-
displayWinner
Display the winner of the game and then close the game- Parameters:
winner- the winner of the game.- See Also:
Window.displayWinner(Player),Terminal.displayWinner(Player)
-