Exemplo n.º 1
0
        private void ProcessResult(MatchResults result)
        {
            Console.WriteLine("You picked {0}, your opponent picked {1}", Enum.GetName(typeof(Choice), result.UserChoice),
                Enum.GetName(typeof(Choice), result.ComputerChoice));

            switch (result.Result)
            {
                case GameResults.Loss:
                    Console.WriteLine("You Lose!");
                    break;
                case GameResults.Tie:
                    Console.WriteLine("You Tied!");
                    break;
                default:
                    Console.WriteLine("You Won!");
                    break;
            }
        }
Exemplo n.º 2
0
        public MatchResults PlayRound(Choice userChoice)
        {
            var result = new MatchResults();
            result.UserChoice = userChoice;
            result.ComputerChoice = _myChoiceSelector.GetOpponentChoice();

            if (result.ComputerChoice == result.UserChoice)
            {
                result.Result = GameResults.Tie;
                return result;
            }

            if (result.ComputerChoice == Choice.Rock && result.UserChoice == Choice.Scissors ||
                result.ComputerChoice == Choice.Scissors && result.UserChoice == Choice.Paper ||
                result.ComputerChoice == Choice.Paper && result.UserChoice == Choice.Rock)
            {
                result.Result = GameResults.Loss;
                return result;
            }

            result.Result = GameResults.Win;
            return result;
        }