Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // introduce and initialize the game
            Console.WriteLine("Welcome to the game of Rock, Paper, Scissors!");
            Console.Write("Please enter your name: ");
            string name = Console.ReadLine();
            var    game = new RpsLogic();

            game.PlayerName = name;

            // Game-play loop
            string playAgain = "yes";

            do
            {
                // Get the human player's choice
                string machineChoice = game.ChooseHand().ToString();  // the machine makes it's move
                Console.Write("Please enter rock, paper, or scissors: ");
                string choice = Console.ReadLine();

                // Get the machine's choice and display the winner
                Console.WriteLine("The machine chose: " + machineChoice);
                string winner = game.WhoWon(choice);
                Console.WriteLine(winner);

                // Do it again?
                Console.WriteLine("---------------");
                Console.Write("Do you want to play again? (yes or no) :");
                playAgain = Console.ReadLine().ToLower();
                Console.WriteLine("---------------");
            } while (playAgain == "yes" || playAgain == "y");
        }
Exemplo n.º 2
0
 public IndexModel(RpsLogic rpsLogic)
 {
     _rpsLogic = rpsLogic;
 }
Exemplo n.º 3
0
 public void OnGet()
 {
     GameData = _rpsLogic.userData;
 }
Exemplo n.º 4
0
        public IActionResult OnPost()
        {
            var game = new RpsLogic();

            return(Page());
        }