Rock, Paper, Scissors

Run Settings
LanguageC#
Language Version
Run Command
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main() { PPTGame pptGame = new PPTGame(); int result = pptGame.CheckWinner(); if (result == 0) { Console.WriteLine("It's a tie!"); } else if (result == 1) { Console.WriteLine("Machine 2 wins!"); } else { Console.WriteLine("Machine 1 wins!"); } } public class PPTGame { public String[] options = {"Rock", "Paper", "Scissors"}; private Random random = new Random(); public int GetMachineChoice() { return random.Next(0, 3); } public int CheckWinner() { int choiceMachine1 = GetMachineChoice(); int choiceMachine2 = GetMachineChoice(); Console.WriteLine("Machine 1's choice: " + options[choiceMachine1]); Console.WriteLine("Machine 2's choice: " + options[choiceMachine2]); if (choiceMachine1 == choiceMachine2) { return 0; // It's a tie } else if ((choiceMachine1 + 1) % 3 == choiceMachine2) { return 1; // Machine 1 wins } else { return 2; // Machine 2 wins } } } }
Editor Settings
Theme
Key bindings
Full width
Lines