Package com.edu.xmum.CST210.Service
Class PlayerService
java.lang.Object
com.edu.xmum.CST210.Service.PlayerService
- All Implemented Interfaces:
IPlayerService
Implementation of the IPlayerService interface.
Provides methods for player-related operations within the maze.
-
Constructor Summary
ConstructorsConstructorDescriptionPlayerService(IMazeService maze, IPlayerModel playerModel) Constructor for PlayerService. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the player has reached the goal.getMaze()Gets the maze model associated with the player.Gets the Player model instance.booleanmovePlayer(int dx, int dy) Checks if the move is valid and moves the player.voidreset()Resets the player's position to the starting point.
-
Constructor Details
-
PlayerService
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:
movePlayerin interfaceIPlayerService- 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:
checkGoalin interfaceIPlayerService- Returns:
- True if the player has reached the goal, false otherwise.
-
getPlayer
Gets the Player model instance.- Specified by:
getPlayerin interfaceIPlayerService- Returns:
- The Player model instance.
-
reset
public void reset()Resets the player's position to the starting point.- Specified by:
resetin interfaceIPlayerService
-
getMaze
Gets the maze model associated with the player.- Specified by:
getMazein interfaceIPlayerService- Returns:
- The maze model.
-