// get each card with the highest, middle and lowest value public void getEachCard() { try { lowestCard = new PokerCard(); highestCard = new PokerCard(); middleCard = new PokerCard(); int lowestValue = allCards.Min(cp => cp.value); int highestValue = allCards.Max(cp => cp.value); lowestCard = allCards.Find(cp => cp.value == lowestValue); highestCard = allCards.Find(cp => cp.value == highestValue); middleCard = allCards.Find(cp => cp != highestCard && cp != lowestCard); } catch (ArgumentNullException ane) { } }
// make a whole deck of cards that consists of 4 suits and 13 values public List <PokerCard> getADeckOfCards() { List <PokerCard> pcDeck = new List <PokerCard>(); for (int i = 0; i < 4; i++) { for (int j = 0; j < 13; j++) { PokerCard pc = new PokerCard { suit = i, value = j }; pcDeck.Add(pc); } } return(pcDeck); }
// parse a card suit and value to a string public string cardToString(PokerCard pc) { string suit = ""; switch (pc.suit) { case 0: suit = "♥"; break; case 1: suit = "♠"; break; case 2: suit = "♣"; break; case 3: suit = "♦"; break; } switch (pc.value) { case 9: return(suit + "J"); case 10: return(suit + "Q"); case 11: return(suit + "K"); case 12: return(suit + "A"); } return(suit + (pc.value + 2)); }