예제 #1
0
        //Problem 5
        public static void CompareCard(string[] inputArg)
        {
            Card cardOne = new CardFactory().CreateCard(inputArg[1], inputArg[0]);
            Card cardTwo = new CardFactory().CreateCard(inputArg[3], inputArg[2]);

            if (cardOne.CompareTo(cardTwo) < 0)
            {
                Console.WriteLine(cardTwo);
            }
            else
            {
                Console.WriteLine(cardOne);
            }
        }
예제 #2
0
        //problem 8

        public static void CardGame()
        {
            string nameOfFirstPlayer  = Console.ReadLine();
            string nameOfSecondPlayer = Console.ReadLine();

            Player firstPlayer  = new Player(nameOfFirstPlayer);
            Player secondPlayer = new Player(nameOfSecondPlayer);

            int cardCount = 1;

            while (cardCount <= 10)
            {
                string[] cardType = Console.ReadLine().Split();
                try
                {
                    CardFactory card    = new CardFactory();
                    Card        newCard = card.CreateCard(cardType[2], cardType[0]);

                    if (cardCount < 6)
                    {
                        firstPlayer.AddCard(newCard);
                    }
                    else
                    {
                        secondPlayer.AddCard(newCard);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    continue;
                }

                cardCount++;
            }

            if (firstPlayer.WinningCard.CardPower >
                secondPlayer.WinningCard.CardPower)
            {
                Console.WriteLine(firstPlayer);
            }
            else
            {
                Console.WriteLine(secondPlayer);
            }
        }
예제 #3
0
        //Problem 3,4
        public static void CardPower(string[] inputArg)
        {
            CardFactory card = new CardFactory();

            Console.WriteLine(card.CreateCard(inputArg[1], inputArg[0]));
        }