# Class MainCabin

java.lang.Object
it.polimi.ingsw.is25am31.model.components.Component
it.polimi.ingsw.is25am31.model.components.MainCabin

All Implemented Interfaces:
  `Serializable`

public class MainCabin extends Component
Represents the main cabin component of a spaceship. The main cabin is the central component that holds crew members and has a specific color. It can accommodate a maximum of 2 crew members.

See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class it.polimi.ingsw.is25am31.model.components.Component

  `connector, id, name, orientation, x, y`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MainCabin(int id, String name, Map<Side,Connector> connector, Side orientation, Color color)`
  Creates a new MainCabin component with the specified properties.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String[]`
  `getAsciiArt()`
  Generates an ASCII art representation of the main cabin component.
  `Color`
  `getColor()`
  Gets the color of the main cabin.
  `int`
  `getCrewMembers()`
  Gets the current number of crew members in the main cabin.
  `boolean`
  `modifyCrewMembers(int change)`
  Modifies the number of crew members in the main cabin by the specified amount.
  `void`
  `setColor(Color color)`
  Sets the color of the main cabin.

  ### Methods inherited from class it.polimi.ingsw.is25am31.model.components.Component

  `activate, addContains, calculateFirePower, calculateThrust, getAlienColor, getCapacity, getConnector, getConnectors, getContains, getCurrentAlien, getId, getMaxGoodValue, getName, getOrientation, getOrientationShield, getPower, getX, getY, isActive, isAlienLifeSupport, isAlienStructural, modifyCapacity, modifyOrientation, protectedSides, removeContains, setOrientationShield, setX, setY`

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

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

- ## Constructor Details

  - ### MainCabin

    public MainCabin(int id, String name, Map<Side,Connector> connector, Side orientation, Color color)
    Creates a new MainCabin component with the specified properties. The cabin is initialized with 2 crew members by default.
    Parameters:
      `id` - the unique identifier for this component
      `name` - the name of the component
      `connector` - a map of connectors indexed by their side position
      `orientation` - the current orientation of the component
      `color` - the color of the main cabin

- ## Method Details

  - ### modifyCrewMembers

    public boolean modifyCrewMembers(int change)
    Modifies the number of crew members in the main cabin by the specified amount. The main cabin can accommodate between 0 and 2 crew members (inclusive).
    Overrides:
      `modifyCrewMembers` in class `Component`
    Parameters:
      `change` - the amount to add (if positive) or subtract (if negative) from the current number of crew members
    Returns:
      `true` if the modification was successfully applied, `false` if the change would result in an invalid number of crew members (less than 0 or greater than 2)

  - ### setColor

    public void setColor(Color color)
    Sets the color of the main cabin.
    Parameters:
      `color` - the new color for the main cabin

  - ### getColor

    public Color getColor()
    Gets the color of the main cabin.
    Returns:
      the current color of the main cabin

  - ### getCrewMembers

    public int getCrewMembers()
    Gets the current number of crew members in the main cabin.
    Overrides:
      `getCrewMembers` in class `Component`
    Returns:
      the number of crew members currently in the cabin

  - ### getAsciiArt

    public String[] getAsciiArt()
    Generates an ASCII art representation of the main cabin component. The representation shows the current crew member count out of the maximum capacity.
    Overrides:
      `getAsciiArt` in class `Component`
    Returns:
      an array of strings representing the ASCII art, with each string being one line