|
|
|
|
@ -2,7 +2,7 @@ import java.util.ArrayList;
|
|
|
|
|
|
|
|
|
|
public class CardGame {
|
|
|
|
|
public Player[] players;
|
|
|
|
|
Pile pot;
|
|
|
|
|
Pile pot = new Pile();
|
|
|
|
|
Card[] draws;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -18,7 +18,6 @@ public class CardGame {
|
|
|
|
|
for (int i = 0; i < numberOfPlayers; i++) {
|
|
|
|
|
players[i] = new Player(String.valueOf(i), deck.getCardsForPlayer(cardsPerPlayer));
|
|
|
|
|
}
|
|
|
|
|
pot = new Pile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Pile createDeck(int numberOfCards) {
|
|
|
|
|
@ -54,13 +53,24 @@ public class CardGame {
|
|
|
|
|
if (max.number < drawn[i].number) {
|
|
|
|
|
maxIndex = i;
|
|
|
|
|
max = drawn[maxIndex];
|
|
|
|
|
} else if (max.number == drawn[i].number) {
|
|
|
|
|
// what if there is no winner?
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (uniqueMaximum(drawn, max, maxIndex)) {
|
|
|
|
|
System.out.printf("Player %d wins this round\n\n", maxIndex);
|
|
|
|
|
players[maxIndex].discardPile.addAll(pot);
|
|
|
|
|
pot.clear();
|
|
|
|
|
} else {
|
|
|
|
|
System.out.printf("No winner in this round\n\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean uniqueMaximum(Card[] draws, Card max, int maxIndex) {
|
|
|
|
|
for (int i = 0; i < draws.length; i++) {
|
|
|
|
|
if (maxIndex != i && max.number == draws[i].number) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean noWinner() {
|
|
|
|
|
|