예제 #1
0
        /// <summary>
        /// Play round, return the winner. If the round is a tie or invalid input is find, retur null
        /// </summary>
        /// <returns>The winner, null if there's no winner</returns>
        private Player PlayRound()
        {
            Play play1 = _player1.GetPlay();
            Play play2 = _player2.GetPlay();

            if (play1 == Play.Invalid || play2 == Play.Invalid)
            {
                Console.WriteLine("Invalid input");
                return(null);
            }

            int winner = GetWinner(play1, play2);

            if (winner == 0)
            {
                Console.WriteLine("Nobody wins");
                return(null);
            }
            else if (winner == -1)
            {
                return(_player1);
            }
            else
            {
                return(_player2);
            }
        }