Class Game

java.lang.Object
battleship.model.Game

public class Game
extends java.lang.Object
Main game class
  • Field Details

    • players

      public final Player[] players
    • currentPlayer

      public Player currentPlayer
  • Constructor Details

    • Game

      public Game​(Player[] players)
  • Method Details

    • getCurrentPlayer

      public Player getCurrentPlayer()
    • getOtherPlayer

      public Player getOtherPlayer()
    • getOtherPlayer

      public Player getOtherPlayer​(Player player)
    • changeCurrentPlayer

      public void changeCurrentPlayer()
    • checkDrownedShips

      public void checkDrownedShips()
      Update ship to know if they're drowned
    • getWinner

      public Player getWinner()
      Returns:
      player 1 if player 2' ships are drowned, or player 2 if player1' ships are drowned, null otherwise
    • move

      public void move​(Pair<java.lang.Integer,​java.lang.Integer> move)
      Play the selected move from current player in grid
      Parameters:
      move - selected player move
    • Play

      public void Play​(View view)
      game loop
      Parameters:
      view - can be Terminal or Window