Package battleship

Interface IGame

All Known Implementing Classes:
Game

public interface IGame
The interface Game.
  • Method Details

    • randomEnemyFire

      String randomEnemyFire()
      Simulates a random enemy firing action on the game board.
      Returns:
      a String indicating the result of the firing action, such as details about a hit, a miss, or other outcomes
    • readEnemyFire

      String readEnemyFire(Scanner in)
      Reads the result of an enemy firing action from input and interprets it.
      Parameters:
      in - the Scanner to read the input from, which provides the details of the enemy fire
      Returns:
      a String describing the outcome of the enemy fire, such as a hit, a miss, or other results
    • fireShots

      void fireShots(List<IPosition> shots)
      Fires a set of shots in a given move.
      Parameters:
      shots - the positions where the shots are fired
    • fireSingleShot

      IGame.ShotResult fireSingleShot(IPosition pos, boolean isRepeated)
      Fires a single shot at the specified position and indicates whether the shot is valid, repeated, and if it hit or sank a ship.
      Parameters:
      pos - the position to fire the shot at, represented as an instance of IPosition
      isRepeated - a boolean indicating if the shot is a repeated attempt at the given position
      Returns:
      a ShotResult containing details such as the validity of the shot, whether it was repeated, the ship (if any) affected, and whether the ship was sunk
    • getMyFleet

      IFleet getMyFleet()
      Gets my fleet.
      Returns:
      my fleet
    • getAlienMoves

      List<IMove> getAlienMoves()
      Gets alien moves
      Returns:
      the alien moves
    • getAlienFleet

      IFleet getAlienFleet()
      Gets the alien fleet
      Returns:
      the alien fleet
    • getMyMoves

      List<IMove> getMyMoves()
      Gets my moves
      Returns:
      my moves
    • getRepeatedShots

      int getRepeatedShots()
      Gets repeated shots.
      Returns:
      the repeated shots
    • getInvalidShots

      int getInvalidShots()
      Gets invalid shots.
      Returns:
      the invalid shots
    • getHits

      int getHits()
      Gets hits.
      Returns:
      the hits
    • getSunkShips

      int getSunkShips()
      Gets sunk ships.
      Returns:
      the sunk ships
    • getRemainingShips

      int getRemainingShips()
      Gets remaining ships.
      Returns:
      the remaining ships
    • printMyBoard

      void printMyBoard(boolean show_shots, boolean show_legend)
      Print my board (my fleet + alien shots).
    • printAlienBoard

      void printAlienBoard(boolean show_shots, boolean show_legend)
      Print the alien board (alien fleet + my shots).
    • over

      void over()