# Class Rocket

java.lang.Object
it.polimi.ingsw.is25am31.model.player.Rocket

All Implemented Interfaces:
  `Serializable`

public class Rocket extends Object implements Serializable
Represents a player's rocket on the game's gameboard, which can be assigned a color and position. The rocket can move across the board while handling collisions with other rockets.

See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Rocket(Gameboard gameboard)`
  Constructs a new rocket associated with a specific gameboard

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `changePosition(int offset)`
  Moves the rocket by a relative offset, handling collisions with other rockets
  `Color`
  `getColor()`
  Returns the color assigned to the rocket
  `int`
  `getPosition()`
  Returns the current position of the rocket
  `void`
  `setColor(Color color)`
  Assigns a color to the rocket
  `void`
  `setPosition(int position)`
  Sets the rocket's position on the gameboard and registers it

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Rocket

    public Rocket(Gameboard gameboard)
    Constructs a new rocket associated with a specific gameboard
    Parameters:
      `gameboard` - reference to the gameboard

- ## Method Details

  - ### getPosition

    public int getPosition()
    Returns the current position of the rocket
    Returns:
      position index on the gameboard

  - ### setPosition

    public void setPosition(int position)
    Sets the rocket's position on the gameboard and registers it
    Parameters:
      `position` - new position index

  - ### changePosition

    public void changePosition(int offset)
    Moves the rocket by a relative offset, handling collisions with other rockets
    Parameters:
      `offset` - number of spaces to move (positive or negative)

  - ### getColor

    public Color getColor()
    Returns the color assigned to the rocket
    Returns:
      Color of the rocket

  - ### setColor

    public void setColor(Color color)
    Assigns a color to the rocket
    Parameters:
      `color` - chosen color for the rocket