Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Rock.Paper.Scissors
- {
- class MainClass
- {
- public static void Main (string[] args)
- {
- bool continueOrEnd = true;
- string userChoice;
- string computerChoice;
- while (continueOrEnd) {
- //Asks the user for his choice//
- Console.WriteLine ("MAKE YOUR CHOICE: ROCK, PAPER, OR SCISSORS?!?");
- userChoice = (Console.ReadLine ()).ToLower();
- //Generates a random integer and uses this to make the computer's choice//
- Random rnd = new Random ();
- int randomNumber = rnd.Next (1, 4);
- if (randomNumber == 1) {
- computerChoice = "rock";
- } else if (randomNumber == 2) {
- computerChoice = "paper";
- } else {
- computerChoice = "scissors";
- }
- //Presents the player with the computer's choice//
- Console.WriteLine ("You chose {0}, and the computer chose {1}.", userChoice, computerChoice);
- //Compares the userChoice and computerChoice and proclaims a winner//
- if (userChoice == computerChoice) {
- Console.WriteLine ("The result is a tie! Balance has been restored to the Force.");
- } else {
- if (userChoice == "rock") {
- if (computerChoice == "paper") {
- Console.WriteLine ("Computer wins. Do or do not: there is no try.");
- } else {
- Console.WriteLine ("You win! The Force is strong with this one.");
- }
- } else if (userChoice == "paper") {
- if (computerChoice == "scissors") {
- Console.WriteLine ("Computer wins: I find your lack of skill disturbing.");
- } else {
- Console.WriteLine ("Don't get cocky, Kid, but you won.");
- }
- } else {
- if (computerChoice == "rock") {
- Console.WriteLine ("Computer wins. Use the force next time, Luke.");
- } else {
- Console.WriteLine ("You win! We may make a Jedi of you yet.");
- }
- }
- }
- //Asks if the player would like to play again//
- Console.WriteLine ("Would you like to play again?");
- userChoice = (Console.ReadLine ()).ToLower();
- if (userChoice == "yes") {
- continueOrEnd = true;
- } else {
- continueOrEnd = false;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement