Skip to content

Instantly share code, notes, and snippets.

@qpfiffer
Created July 21, 2011 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qpfiffer/1096351 to your computer and use it in GitHub Desktop.
Save qpfiffer/1096351 to your computer and use it in GitHub Desktop.
Card bs
for (int i=0;i<nHands;i++) {
ArrayList<pCard.Card> player = new ArrayList<pCard.Card>();
int playerScore = 0;
for (int j=0;j<cardsPerHand;j++) {
try {
player.add(deck.get(i+(j*nHands)));
} catch (IndexOutOfBoundsException e) {
System.out.println("Not enough cards for that player/hands combination.");
System.exit(1);
}
int curRank = deck.get(i+(j*nHands)).rank.getValue();
int curSuit = deck.get(i+(j*nHands)).suit.ordinal()+1;
playerScore += curRank * curSuit;
}
printDeck(player, cardsPerLine);
System.out.print("\nscore="+playerScore+"\n\n");
}
...
public enum Rank {
DEUCE, THREE, FOUR, FIVE, SIX,
SEVEN, EIGHT, NINE, TEN, JACK(10),
QUEEN(10), KING(10),ACE(11);
private final int value;
Rank() {
value = this.ordinal()+2;
}
Rank(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment