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 grid
    void displayBoard()
    Display all grids
    void displayWinner​(Player winner)
    Display the winner of the game and then close the game
    void setShips​(Player player)
    Ask player to set position of its ships
  • Field Details

    • shipsSize

      static final int[] shipsSize
  • Method Details

    • setShips

      void setShips​(Player player) throws java.lang.InterruptedException
      Ask player to set position of its ships
      Parameters:
      player - player instance we ask
      Throws:
      java.lang.InterruptedException - see Window.setShips(Player)
    • displayBoard

      void displayBoard()
      Display all grids
    • chooseMove

      Pair<java.lang.Integer,​java.lang.Integer> chooseMove​(Player player) throws java.lang.InterruptedException
      ask 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 - see Window.chooseMove(Player)
    • displayWinner

      void displayWinner​(Player winner)
      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)