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:
@@ -90,6 +90,20 @@ private void initializeDrawPile() {
|
|||||||
addBonusCards(BonusCard.TURBO, AMOUNT_OF_TURBO_CARDS);
|
addBonusCards(BonusCard.TURBO, AMOUNT_OF_TURBO_CARDS);
|
||||||
addBonusCards(BonusCard.SWAP, AMOUNT_OF_SWAP_CARDS);
|
addBonusCards(BonusCard.SWAP, AMOUNT_OF_SWAP_CARDS);
|
||||||
addBonusCards(BonusCard.SHIELD, AMOUNT_OF_SHIELD_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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user