Created
July 21, 2011 01:55
-
-
Save qpfiffer/1096351 to your computer and use it in GitHub Desktop.
Card bs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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