Class StudentFactory
java.lang.Object
it.polimi.ingsw.server.model.game_logic.StudentFactory
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetNStudents(int n) getStudent(Color student) This method returns the requested student color from the student supply and updates it accordinglybooleanisEmpty()This method returns true if the student supply is emptyintThis method returns the total number of students left in the supply
-
Field Details
-
studentSupply
-
-
Constructor Details
-
StudentFactory
public StudentFactory()
-
-
Method Details
-
getStudent
- 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
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
- Returns:
- a random student, each color is equally likely to spawn, this method DOES NOT update the studentSupply
-
getNStudents
- 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
-