Class StudentBag

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

public class StudentBag extends Object implements Serializable
The StudentBag contains a limited number of PawnColour ordered randomly.
See Also:
  • Field Details

  • Constructor Details

    • StudentBag

      public StudentBag(int numOfStudentsPerColour)
      Construct the bag
      Parameters:
      numOfStudentsPerColour - the number of each color of students to put in the bag
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Check to see if the bag is empty
      Returns:
      true if the bag is empty
    • multipleExtraction

      public List<PawnColour> multipleExtraction(int extractions)
      Extract multiple PawnColours at once
      Parameters:
      extractions - number of maximum extractions to carry out. The number of extracted students may be lower than the number specified as input, if the bag empties out during the extraction
      Returns:
      an Unmodifiable List containing the extracted PawnColour
    • extract

      public PawnColour extract() throws EmptyContainerException
      Extract a single PawnColour from the bag
      Returns:
      the extracted student
      Throws:
      EmptyContainerException - if the bag is empty
    • getSize

      public int getSize()
      Check the remaining students in the bag
      Returns:
      the size of the bag
    • appendAndShuffle

      public void appendAndShuffle(PawnColour colour)
      Put a student back in the bag and shuffle it in.
      Parameters:
      colour - the PawnColour to add back to the bag
    • removeContentReference

      public void removeContentReference()
      Used to sanitize Model. Removes information about the internal contents of the bag, making the spoofing of technically hidden information impossible on the client side.