Class Island

java.lang.Object
it.polimi.ingsw.Model.Island
All Implemented Interfaces:
Serializable

public class Island extends Object implements Serializable
Islands are containers of PawnColours and Tower.The islands can be grouped through IslandGroup
See Also:
  • Field Details

  • Constructor Details

    • Island

      public Island(int id)
      Construct an Island, assinging an ID to it.
      Parameters:
      id - the id of the constructed Island.
  • Method Details

    • getId

      public int getId()
      Returns:
      the ID of the Island
    • getStudents

      public List<PawnColour> getStudents()
      Returns:
      the PawnColours contained in the Island
    • getTowerColour

      public OptionalValue<TowerColour> getTowerColour()
      If a tower is present, return a non-empty OptionalValue
      Returns:
      the colour of the contained tower wrapped in a OptionalValue
    • addStudent

      public void addStudent(PawnColour p)
      a student can be added to the Island through this method
      Parameters:
      p - the PawnColour to add to the island
    • swapTower

      public void swapTower(Tower t)
      a Tower may need to be swapped or added during the Island's lifespan, this method can be used for that
      Parameters:
      t - the new Tower to be put on the island. the old tower (if any was present) will be returned to its rightful storage automatically. The input can be null, this removes the tower from the island