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
Modifier and TypeFieldDescriptionprivate boolean
private static final long
private ArrayList<PawnColour>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
appendAndShuffle
(PawnColour colour) Put a student back in the bag and shuffle it in.extract()
Extract a singlePawnColour
from the bagint
getSize()
Check the remaining students in the bagboolean
isEmpty()
Check to see if the bag is emptymultipleExtraction
(int extractions) Extract multiplePawnColour
s at oncevoid
Used 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 multiplePawnColour
s 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 extractedPawnColour
-
extract
Extract a singlePawnColour
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
Put a student back in the bag and shuffle it in.- Parameters:
colour
- thePawnColour
to 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.
-