public bool DealInitial() { foreach (BlackJackHand hand in hands) { BlackJackCard card1 = deck.DealCard(); BlackJackCard card2 = deck.DealCard(); if (card1 == null || card2 == null) { return(false); } hand.AddCard(card2); hand.AddCard(card1); } return(true); }
static void Main(string[] args) { Deck deck1 = new Deck(); int j = 1; for (int i = 0; i < 52; i++) { Console.WriteLine(j + ". card is {0}", deck1.DealCard()); j++; } Console.WriteLine("\nYour deck has been shuffled. \n"); deck1.Shuffle(); int k = 1; for (int i = 0; i < 52; i++) { Console.WriteLine(k + ". card is {0}", deck1.DealCard()); k++; } }
static void Main(string[] args) { Deck pokerDesk = new Deck(); pokerDesk.shuffle(52); for (int i = 0; i < 52; i++) { Console.Write("{0, -15}", pokerDesk.DealCard()); if ((i + 1) % 13 == 0) { Console.WriteLine(); Console.WriteLine(); } } Console.ReadLine(); }
static void Main(string[] args) { //Start of program. Program asks which deck of cards the user wants Console.WriteLine("Which deck of card would you like to see? \nPlease input Normal or Shuffled: "); string deckchoise = Console.ReadLine(); do { if (deckchoise.Equals("Normal")) { Console.WriteLine("Normal Deck: \n"); Console.WriteLine( //Clubs "Ace of Clubs\n" + "2 of Clubs\n" + "3 of Clubs\n" + "4 of Clubs\n" + "5 of Clubs\n" + "6 of Clubs\n" + "7 of Clubs\n" + "8 of Clubs\n" + "9 of Clubs\n" + "10 of Clubs\n" + "Jack of Clubs\n" + "Queen of Clubs\n" + "King of Clubs\n" + //Diamonds "Ace of Diamonds\n" + "2 of Diamonds\n" + "3 of Diamonds\n" + "4 of Diamonds\n" + "5 of Diamonds\n" + "6 of Diamonds\n" + "7 of Diamonds\n" + "8 of Diamonds\n" + "9 of Diamonds\n" + "10 of Diamonds\n" + "Jack of Diamonds\n" + "Queen of Diamonds\n" + "King of Diamonds\n" + //Hearts "Ace of Hearts\n" + "2 of Hearts\n" + "3 of Hearts\n" + "4 of Hearts\n" + "5 of Hearts\n" + "6 of Hearts\n" + "7 of Hearts\n" + "8 of Hearts\n" + "9 of Hearts\n" + "10 of Hearts\n" + "Jack of Hearts\n" + "Queen of Hearts\n" + "King of Hearts\n" + //Spades "Ace of Spades\n" + "2 of Spades\n" + "3 of Spades\n" + "4 of Spades\n" + "5 of Spades\n" + "6 of Spades\n" + "7 of Spades\n" + "8 of Spades\n" + "9 of Spades\n" + "10 of Spades\n" + "Jack of Spades\n" + "Queen of Spades\n" + "King of Spades\n\n\n"); Console.WriteLine("Would you like to shuffle the deck? \nPlease input Yes or No: "); string shufflechoise = Console.ReadLine(); do { if (shufflechoise.Equals("Yes")) { Console.WriteLine("Shuffled Deck: \n"); Deck deck1 = new Deck(); deck1.Shuffle(); for (int i = 0; i < 52; i++) { Console.Write("{0,-19}", deck1.DealCard()); if ((i + 1) % 1 == 0) { Console.WriteLine(); } } Console.ReadLine(); } else if (shufflechoise.Equals("No")) { //Console.WriteLine("The above deck is your deck"); Deck deck1 = new Deck(); Console.Write(deck1.DealCard()); Console.ReadLine(); } else { Console.WriteLine("Sorry, I did not recognise your input. Please try again."); } //Program doesn't recognise valid input Console.ReadLine(); } while (shufflechoise == "0"); } else if (deckchoise.Equals("Shuffled")) { Console.WriteLine("Shuffled Deck: \n"); Deck deck1 = new Deck(); deck1.Shuffle(); for (int i = 0; i < 52; i++) { Console.Write("{0,-19}", deck1.DealCard()); if ((i + 1) % 1 == 0) { Console.WriteLine(); } } Console.ReadLine(); } else { Console.WriteLine("Sorry, I did not recognise your input. Please try again."); } //Program doesn't recognise valid input Console.ReadLine(); } while (deckchoise == "0"); }
static void Main(string[] args) { Deck deck1 = new Deck(); int k; for (int i = 0; i < 2; i++) { for (int j = 1; j < (6 + 1); j++) { deck1.Cards.Add(new Card { cardsuit = i, cardvalue = j }); } } if (deck1.IsSorted()) { Console.WriteLine("\nYes the incomplete Deck is Sorted\n"); } for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard()) { Console.Write("drew: a(n) {0}\n", Card.GetCardName(tmpcard)); } Console.WriteLine("\n\nLet's Shuffle The Deck!\n\n"); deck1.Shuffle(); for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard()) { Console.Write("drew: a(n) {0}\n", Card.GetCardName(tmpcard)); } Console.WriteLine("\nLet's Initialize a full deck\n"); deck1.InitializeFullDeck(); bool tmp = deck1.AreCardsUnique(); if (tmp && deck1.Cards.Count() == 52) { Console.WriteLine("We have 52 card and no duplicates - we have an official set!\n\n"); } for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard()) { Console.Write("drew: a(n) {0}\n", Card.GetCardName(tmpcard)); } Console.WriteLine("\n\nLet's Shuffle The Deck!\n\n"); deck1.Shuffle(); if (!deck1.IsSorted()) { Console.WriteLine("\nThe Deck is not Sorted\n"); } k = 1; foreach (var card in deck1.Cards) { Console.WriteLine("({0}) drew a {1}", k++, Card.GetCardName(card)); } Console.WriteLine("\n\nLet's Sort The Deck!\n\n"); deck1.Sort(); if (deck1.IsSorted()) { Console.WriteLine("\nYes the Deck is Sorted\n"); } k = 1; foreach (var card in deck1.Cards) { Console.WriteLine("({0}) drew a(n) {1}", k++, Card.GetCardName(card)); } Console.ReadLine(); }
static void Main(string[] args) { Deck deck1 = new Deck(); int k; for (int i = 0; i < 2; i++) { for (int j = 1; j< (6 + 1); j++) { deck1.Cards.Add(new Card { cardsuit = i, cardvalue = j }); } } if (deck1.IsSorted()) { Console.WriteLine("\nYes the incomplete Deck is Sorted\n"); } for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard()) { Console.Write("drew: a(n) {0}\n", Card.GetCardName(tmpcard)); } Console.WriteLine("\n\nLet's Shuffle The Deck!\n\n"); deck1.Shuffle(); for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard()) { Console.Write("drew: a(n) {0}\n", Card.GetCardName(tmpcard)); } Console.WriteLine("\nLet's Initialize a full deck\n"); deck1.InitializeFullDeck(); bool tmp = deck1.AreCardsUnique(); if (tmp && deck1.Cards.Count() == 52) Console.WriteLine("We have 52 card and no duplicates - we have an official set!\n\n"); for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard()) { Console.Write("drew: a(n) {0}\n", Card.GetCardName(tmpcard)); } Console.WriteLine("\n\nLet's Shuffle The Deck!\n\n"); deck1.Shuffle(); if (!deck1.IsSorted()) { Console.WriteLine("\nThe Deck is not Sorted\n"); } k = 1; foreach (var card in deck1.Cards) Console.WriteLine("({0}) drew a {1}", k++, Card.GetCardName(card)); Console.WriteLine("\n\nLet's Sort The Deck!\n\n"); deck1.Sort(); if (deck1.IsSorted()) { Console.WriteLine("\nYes the Deck is Sorted\n"); } k = 1; foreach (var card in deck1.Cards) Console.WriteLine("({0}) drew a(n) {1}", k++, Card.GetCardName(card)); Console.ReadLine(); }