|
|
|
@ -1,4 +1,8 @@
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static java.util.Collections.shuffle;
|
|
|
|
|
|
|
|
//import org-apache-commons-lang3.ArrayUtils;
|
|
|
|
|
|
|
|
|
|
|
|
public class CardGame {
|
|
|
|
public class CardGame {
|
|
|
|
public Player[] players;
|
|
|
|
public Player[] players;
|
|
|
|
@ -11,7 +15,7 @@ public class CardGame {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public CardGame(int numberOfCards, int numberOfPlayers) {
|
|
|
|
public CardGame(int numberOfCards, int numberOfPlayers) {
|
|
|
|
Pile deck = createDeck(numberOfCards);
|
|
|
|
Pile deck = createDeck(numberOfCards);
|
|
|
|
deck.shuffle();
|
|
|
|
shuffle(deck, new Random());
|
|
|
|
this.players = new Player[numberOfPlayers];
|
|
|
|
this.players = new Player[numberOfPlayers];
|
|
|
|
draws = new Card[numberOfPlayers];
|
|
|
|
draws = new Card[numberOfPlayers];
|
|
|
|
int deckCount = deck.count();
|
|
|
|
int deckCount = deck.count();
|
|
|
|
@ -65,6 +69,7 @@ public class CardGame {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
System.out.printf("Player %d wins this round\n\n", maxIndex);
|
|
|
|
System.out.printf("Player %d wins this round\n\n", maxIndex);
|
|
|
|
players[maxIndex].discardPile.addAll(pot);
|
|
|
|
players[maxIndex].discardPile.addAll(pot);
|
|
|
|
|
|
|
|
pot.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean noWinner() {
|
|
|
|
private boolean noWinner() {
|
|
|
|
|