Class StudentFactory

java.lang.Object
it.polimi.ingsw.server.model.game_logic.StudentFactory

public class StudentFactory extends Object
  • Field Details

  • Constructor Details

    • StudentFactory

      public StudentFactory()
  • Method Details

    • getStudent

      public Color getStudent() throws EmptyStudentSupplyException
      Returns:
      a random student drawn from the supply, the student is finally removed from the supply.
      Throws:
      EmptyStudentSupplyException - if the student supply (representing the bag) is empty.
    • getStudent

      public Color getStudent(Color student) throws EmptyStudentSupplyException
      This method returns the requested student color from the student supply and updates it accordingly
      Parameters:
      student - is the student to be drawn from the supply
      Returns:
      the student drawn from the supply
      Throws:
      EmptyStudentSupplyException - if the student supply doesn't contain any student of the inputted color
    • generateStudent

      public Color generateStudent()
      Returns:
      a random student, each color is equally likely to spawn, this method DOES NOT update the studentSupply
    • getNStudents

      public List<Color> getNStudents(int n) throws EmptyStudentSupplyException
      Parameters:
      n - number of students to extract from the supply
      Returns:
      a list containing the n students that are randomly extracted from the supply
      Throws:
      IllegalArgumentException - if(n invalid input: '<' 0)
      EmptyStudentSupplyException - if the student supply (representing the bag) is empty.
    • isEmpty

      public boolean isEmpty()
      This method returns true if the student supply is empty
      Returns:
      true if the supply is empty, false otherwise
    • numberOfStudentsLeft

      public int numberOfStudentsLeft()
      This method returns the total number of students left in the supply
      Returns:
      an int representing the number of students left in the supply