Updated 'Game' class.

Updated the 'Game' class by adding the 'draw' method to it. In Addition, the 'initializeDrawPile' method was updated by shuffling the 'drawPile' attribute after filling it.
This commit is contained in:
Daniel Grigencha
2024-12-05 23:27:06 +01:00
parent 1214d3c87c
commit 0ce8184069

View File

@@ -90,6 +90,20 @@ private void initializeDrawPile() {
addBonusCards(BonusCard.TURBO, AMOUNT_OF_TURBO_CARDS);
addBonusCards(BonusCard.SWAP, AMOUNT_OF_SWAP_CARDS);
addBonusCards(BonusCard.SHIELD, AMOUNT_OF_SHIELD_CARDS);
Collections.shuffle(this.drawPile);
}
/**
* This method will be used to remove the first card of the drawPile attribute of Game class.
*
* @return first card as a BonusCard enumeration.
*/
public BonusCard draw() {
if (!this.drawPile.isEmpty()) {
return this.drawPile.remove(0);
}
return null;
}
/**