예제 #1
0
파일: Game.cs 프로젝트: vladasp/traineeship
 public Game()
 {
     currentCard = 0;
     playDeck = new Deck(true);
     playDeck.LastCardDrawn += new LastCardDrawnHandler(Reshuffle);
     playDeck.Shuffle();
     discardedCards = new Cards();
 }
예제 #2
0
 public void Show()
 {
     Console.WriteLine(@"
     Напишите клиентское консольное приложение для библиотеки  Ch10CardLib,
     позволяющее вытягивать сразу пять карт из перетасованной колоды (объекта Deck).
     Если все пять карт оказываются одной масти, их названия должны быть выведены
     на консоль вместе с текстом Flush!; в противном случае приложение должно
     завершит работу после просмотра 50 карт, с выводом текста No flush.
                     ");
     Deck myDeck = new Deck();
     myDeck.Shuffle();
     List<Card> tempCard = new List<Card>();
     Random genrateNumber = new Random();
     int cardNumber = genrateNumber.Next(52);
     int countFlash = 0;
     for (int i = 5; i <= 50; i += 5)
     {
         tempCard.Clear();
         countFlash = 0;
         for (int j = 0; j < 5; j++)
         {
             tempCard.Add(myDeck.GetCard(j));
             if (tempCard[0].rank == tempCard[j].rank)
             {
                 countFlash += 1;
             }
         }
         if (countFlash == 5)
         {
             Console.WriteLine("Flash! :-)");
             for (int c = 0; c < tempCard.Count; c++)
             {
                 if (i != 5)
                     Console.WriteLine("{0},", tempCard[c].ToString());
                 else
                     Console.WriteLine("{0}\n", tempCard[c].ToString());
             }
         }
         else
         {
             Console.WriteLine("No flash :-(\nYou played {0} times\n", i/5);
         }
     }
     Console.ReadKey();
 }
예제 #3
0
파일: Game.cs 프로젝트: vladasp/traineeship
 private void Reshuffle(Deck currentDeck)
 {
     Console.WriteLine("Discarded cards reshuffled into deck.");
     // Отброшенные карты перетасованы и помещены в колоду
     currentDeck.Shuffle();
     discardedCards.Clear();
     currentCard = 0;
 }
예제 #4
0
파일: Deck.cs 프로젝트: vladasp/traineeship
 public object Clone()
 {
     Deck newDeck = new Deck(cards.Clone() as Cards);
     return newDeck;
 }