Class PlayerService

java.lang.Object
com.edu.xmum.CST210.Service.PlayerService
All Implemented Interfaces:
IPlayerService

public class PlayerService extends Object implements IPlayerService
Implementation of the IPlayerService interface. Provides methods for player-related operations within the maze.
  • Constructor Details

    • PlayerService

      public PlayerService(IMazeService maze, IPlayerModel playerModel)
      Constructor for PlayerService. Uses dependency injection to initialize the player and maze services.
      Parameters:
      maze - The maze service instance.
      playerModel - The player model instance.
  • Method Details

    • movePlayer

      public boolean movePlayer(int dx, int dy)
      Checks if the move is valid and moves the player.
      Specified by:
      movePlayer in interface IPlayerService
      Parameters:
      dx - The delta x value for the move.
      dy - The delta y value for the move.
      Returns:
      True if the move is valid and the player is moved, false otherwise.
    • checkGoal

      public boolean checkGoal()
      Checks if the player has reached the goal.
      Specified by:
      checkGoal in interface IPlayerService
      Returns:
      True if the player has reached the goal, false otherwise.
    • getPlayer

      public IPlayerModel getPlayer()
      Gets the Player model instance.
      Specified by:
      getPlayer in interface IPlayerService
      Returns:
      The Player model instance.
    • reset

      public void reset()
      Resets the player's position to the starting point.
      Specified by:
      reset in interface IPlayerService
    • getMaze

      public IMazeModel getMaze()
      Gets the maze model associated with the player.
      Specified by:
      getMaze in interface IPlayerService
      Returns:
      The maze model.