Package it.polimi.ingsw.Model
Class StudentBag
java.lang.Object
it.polimi.ingsw.Model.StudentBag
- All Implemented Interfaces:
Serializable
The StudentBag contains a limited number of
PawnColour ordered randomly.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate static final longprivate ArrayList<PawnColour> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendAndShuffle(PawnColour colour) Put a student back in the bag and shuffle it in.extract()Extract a singlePawnColourfrom the bagintgetSize()Check the remaining students in the bagbooleanisEmpty()Check to see if the bag is emptymultipleExtraction(int extractions) Extract multiplePawnColours at oncevoidUsed to sanitizeModel.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
studentBag
-
isEmpty
private boolean isEmpty
-
-
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
Extract multiplePawnColours 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
Listcontaining the extractedPawnColour
-
extract
Extract a singlePawnColourfrom 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
Put a student back in the bag and shuffle it in.- Parameters:
colour- thePawnColourto add back to the bag
-
removeContentReference
public void removeContentReference()Used to sanitizeModel. Removes information about the internal contents of the bag, making the spoofing of technically hidden information impossible on the client side.
-