예제 #1
0
파일: Program.cs 프로젝트: wompadan/poker
        public static void Main(string[] args)
        {
            // NUnit inexplicably refused to work for me, so I had to roll my own dirty version of a test suite
            // Please feel free to review these tests.
            TestRunner.RunTests();

            // You can also test the code that did get completed by modifying the following hands
            string handA = "AD KC QS JD 10C";
            string handB = "9H 8H 6H 5H J";

            HandRanker ranker = new HandRanker();
            int        result = ranker.CompareHands(handA, handB);

            switch (result)
            {
            case 1:
                Console.WriteLine($"{handA} beats {handB}, hands down.");
                break;

            case -1:
                Console.WriteLine($"{handA} is beaten by {handB}, what an upset!");
                break;

            case 0:
                Console.WriteLine($"{handA} and {handB} split the pot.");
                break;
            }
        }
예제 #2
0
        public int Execute(ref int totalTests)
        {
            totalTests += 1;

            CardEntity[] handA        = CardFactory.GenerateHand(_a);
            CardEntity[] handB        = CardFactory.GenerateHand(_b);
            int          actualResult = _ranker.CompareHands(handA, handB);

            if (actualResult != _result)
            {
                Console.WriteLine($"{_a} vs {_b} should result in {_result}, not {actualResult}.");
                Console.WriteLine($"A: {_ranker.GetScore(handA)} vs B: {_ranker.GetScore(handB)}");
                return(0);
            }

            return(1);
        }