# Class CargoHold

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

All Implemented Interfaces:
  `Serializable`

public class CargoHold extends Component
Represents a cargo hold component capable of storing goods with specific constraints. The cargo hold has a defined maximum capacity and can optionally accept special goods.

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
  `CargoHold(int id, String name, Map<Side,Connector> connector, Side orientation, int capacity, boolean special)`
  Constructs a cargo hold with specified properties

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `addContains(Good good)`
  Attempts to add a good to the hold
  `String[]`
  `getAsciiArt()`
  Returns an ASCII art representation of the cargo hold, displaying its type, capacity, and stored goods
  `int`
  `getCapacity()`
  `List<Good>`
  `getContains()`
  Returns a list of goods currently stored
  `int`
  `getMaxGoodValue()`
  `boolean`
  `removeContains(Good good)`
  Removes a specific good from the hold

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

  `activate, calculateFirePower, calculateThrust, getAlienColor, getConnector, getConnectors, getCrewMembers, getCurrentAlien, getId, getName, getOrientation, getOrientationShield, getPower, getX, getY, isActive, isAlienLifeSupport, isAlienStructural, modifyCapacity, modifyCrewMembers, modifyOrientation, protectedSides, setOrientationShield, setX, setY`

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

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

- ## Constructor Details

  - ### CargoHold

    public CargoHold(int id, String name, Map<Side,Connector> connector, Side orientation, int capacity, boolean special)
    Constructs a cargo hold with specified properties
    Parameters:
      `id` - unique component identifier
      `name` - descriptive name of the cargo hold
      `connector` - map of side-to-connector mappings
      `orientation` - initial orientation of the component
      `capacity` - maximum storage capacity
      `special` - whether RED goods are accepted

- ## Method Details

  - ### getCapacity

    public int getCapacity()
    Overrides:
      `getCapacity` in class `Component`

  - ### addContains

    public boolean addContains(Good good)
    Attempts to add a good to the hold
    Overrides:
      `addContains` in class `Component`
    Parameters:
      `good` - the Good to add
    Returns:
      true if the good was added, false otherwise

  - ### removeContains

    public boolean removeContains(Good good)
    Removes a specific good from the hold
    Overrides:
      `removeContains` in class `Component`
    Parameters:
      `good` - the Good to remove
    Returns:
      true if the good was removed, false if it was not present

  - ### getContains

    public List<Good> getContains()
    Returns a list of goods currently stored
    Overrides:
      `getContains` in class `Component`
    Returns:
      unmodifiable list of goods

  - ### getAsciiArt

    public String[] getAsciiArt()
    Returns an ASCII art representation of the cargo hold, displaying its type, capacity, and stored goods
    Overrides:
      `getAsciiArt` in class `Component`
    Returns:
      array of ASCII art lines

  - ### getMaxGoodValue

    public int getMaxGoodValue()
    Overrides:
      `getMaxGoodValue` in class `Component`