└── Program.cs /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class Program 4 | { 5 | static void Main(string[] args) 6 | { 7 | string[] choices = { "Rock", "Paper", "Scissors" }; 8 | const int RockChoice = 1; 9 | const int PaperChoice = 2; 10 | const int ScissorsChoice = 3; 11 | 12 | string rock = 13 | @" 14 | _______ 15 | ---' ____) 16 | (_____) 17 | (_____) 18 | (____) 19 | ---.__(___) 20 | "; 21 | 22 | string paper = 23 | @" 24 | _______ 25 | ---' ____)____ 26 | ______) 27 | _______) 28 | _______) 29 | ---.__________) 30 | "; 31 | 32 | string scissors = 33 | @" 34 | _______ 35 | ---' ____)____ 36 | ______) 37 | __________) 38 | (____) 39 | ---.__(___) 40 | "; 41 | 42 | bool validInput = false; 43 | 44 | Random random = new Random(); 45 | int randomIndex = random.Next(choices.Length); 46 | string randomChoice = choices[randomIndex]; 47 | 48 | for (int i = 1; i <= choices.Length; i++) 49 | { 50 | Console.WriteLine($"{i}) {choices[i - 1]}"); 51 | } 52 | 53 | string strippedChoice = GetUserChoice(); 54 | 55 | while (!validInput) 56 | { 57 | if ( 58 | strippedChoice != RockChoice.ToString() 59 | && strippedChoice != PaperChoice.ToString() 60 | && strippedChoice != ScissorsChoice.ToString() 61 | ) 62 | { 63 | strippedChoice = GetUserChoice(); 64 | } 65 | else 66 | { 67 | switch (strippedChoice) 68 | { 69 | case "1": 70 | Console.WriteLine("\nYou selected: Rock!"); 71 | Console.WriteLine(rock); 72 | Console.WriteLine("The bot selected: " + randomChoice + "!"); 73 | if (randomChoice == "Rock") 74 | { 75 | Console.WriteLine(rock); 76 | } 77 | else if (randomChoice == "Paper") 78 | { 79 | Console.WriteLine(paper); 80 | } 81 | else 82 | { 83 | Console.WriteLine(scissors); 84 | } 85 | if (strippedChoice == "1" && randomChoice == "Scissors") 86 | { 87 | Console.WriteLine("You won!\n"); 88 | } 89 | else if (randomChoice == "Rock") 90 | { 91 | Console.WriteLine("It's a tie!\n"); 92 | } 93 | else 94 | { 95 | Console.WriteLine("The bot wins!\n"); 96 | } 97 | break; 98 | case "2": 99 | Console.WriteLine("\nYou selected: Paper!"); 100 | Console.WriteLine(paper); 101 | Console.WriteLine("The bot selected: " + randomChoice + "!"); 102 | if (randomChoice == "Rock") 103 | { 104 | Console.WriteLine(rock); 105 | } 106 | else if (randomChoice == "Paper") 107 | { 108 | Console.WriteLine(paper); 109 | } 110 | else 111 | { 112 | Console.WriteLine(scissors); 113 | } 114 | if (strippedChoice == "2" && randomChoice == "Rock") 115 | { 116 | Console.WriteLine("You won!\n"); 117 | } 118 | else if (randomChoice == "Paper") 119 | { 120 | Console.WriteLine("It's a tie!\n"); 121 | } 122 | else 123 | { 124 | Console.WriteLine("The bot wins!\n"); 125 | } 126 | break; 127 | case "3": 128 | Console.WriteLine("\nYou selected: Scissors!"); 129 | Console.WriteLine(scissors); 130 | Console.WriteLine("The bot selected: " + randomChoice + "!"); 131 | if (randomChoice == "Rock") 132 | { 133 | Console.WriteLine(rock); 134 | } 135 | else if (randomChoice == "Paper") 136 | { 137 | Console.WriteLine(paper); 138 | } 139 | else 140 | { 141 | Console.WriteLine(scissors); 142 | } 143 | if (strippedChoice == "3" && randomChoice == "Paper") 144 | { 145 | Console.WriteLine("You won!\n"); 146 | } 147 | else if (randomChoice == "Scissors") 148 | { 149 | Console.WriteLine("It's a tie!\n"); 150 | } 151 | else 152 | { 153 | Console.WriteLine("The bot wins!\n"); 154 | } 155 | break; 156 | default: 157 | break; 158 | } 159 | validInput = true; 160 | } 161 | } 162 | } 163 | 164 | static string GetUserChoice() 165 | { 166 | Console.Write("Rock, Paper, or Scissors: "); 167 | string choice = Console.ReadLine(); 168 | string strippedChoice = choice.Replace(" ", ""); 169 | return strippedChoice; 170 | } 171 | } 172 | --------------------------------------------------------------------------------