Advertisement
opsftw

Rock Paper Scizors

Aug 11th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6.  
  7. /* * * * * * * * * * * * *
  8. * Rock, Paper, Scissors!*
  9. *                       *
  10. * BY: OPSFTW            *
  11. * DATE: 1/23/2012       *
  12. * TIME: 4:08am          *
  13. * * * * * * * * * * * * */
  14.  
  15.  
  16.  
  17. namespace RockPaperScissors
  18. {
  19.     class Program
  20.     {
  21.         static void Main()
  22.         {
  23.             string PlayStat = "Tied!";
  24.             int Wins = 0;
  25.             int Loss = 0;
  26.             int Ties = 0;
  27.             int Score = 0;
  28.             int Comp = 0;
  29.             Start:
  30.             //First we declare the variables
  31.             string UserMoveStr;
  32.             int UserMoveInt;
  33.             string CompMoveStr;
  34.             int CompMoveInt;
  35.             UserMoveInt = 0;
  36.             Console.Write(":> Player's score: {0}", Score);
  37.             Console.WriteLine("\t Computer's score: {0}", Comp);
  38.             Console.Write(":> Wins: {0}", Wins);
  39.             Console.Write("\t Loss: {0}", Loss);
  40.             Console.WriteLine("\t Ties: {0}", Ties);
  41.             Console.WriteLine(":> You are: {0}", PlayStat);
  42.             Console.WriteLine(":> --------------------------");
  43.             Console.WriteLine(":> Rock:1 Paper:2 Scissors:3");
  44.             Console.Write(":>::");
  45.             UserMoveStr = Console.ReadLine();
  46.             if (UserMoveStr == "1")
  47.             {
  48.                 UserMoveInt = 1;
  49.                 Console.WriteLine("You chose: Rock");
  50.             }
  51.             else if (UserMoveStr == "2")
  52.             {
  53.                 UserMoveInt = 2;
  54.                 Console.WriteLine("You chose: Paper");
  55.             }
  56.             else if (UserMoveStr == "3")
  57.             {
  58.                 UserMoveInt = 3;
  59.                 Console.WriteLine("You chose: Scissors");
  60.             }
  61.             else
  62.             {
  63.                 Console.Clear();
  64.                 Console.WriteLine("\a ::ERROR::");
  65.                 goto Start;
  66.             }
  67.  
  68.  
  69.  
  70.             Console.WriteLine(""); //To sepperate the Users move from the computers move
  71.  
  72.  
  73.  
  74.             //Now for he computer to make its move
  75.             Random randomGenerator = new Random();
  76.             CompMoveInt = randomGenerator.Next(1, 3);
  77.             if (CompMoveInt == 1)
  78.             {
  79.                 CompMoveStr = "Rock";
  80.                 Console.WriteLine("The computer chose: {0}", CompMoveStr);
  81.             }
  82.             else if (CompMoveInt == 2)
  83.             {
  84.                 CompMoveStr = "Paper";
  85.                 Console.WriteLine("The computer chose: {0}", CompMoveStr);
  86.             }
  87.             else if (CompMoveInt == 2)
  88.             {
  89.                 CompMoveStr = "Scissors";
  90.                 Console.WriteLine("The computer chose: {0}", CompMoveStr);
  91.             }
  92.  
  93.  
  94.             Console.WriteLine(""); //To sepperate for visual appeal
  95.  
  96.             Console.WriteLine("//////////////////////////////////"); //To sepperate the results from the moves
  97.  
  98.             Console.WriteLine(""); //To sepperate for visual appeal
  99.  
  100.             //Now to calculate the winner!
  101.             if (UserMoveInt == 1)
  102.             {
  103.                 if (CompMoveInt == 1)
  104.                 {
  105.                     Console.WriteLine("Tie!");
  106.                     UserMoveStr = Console.ReadLine();
  107.                     Ties = Ties + 1;
  108.                 }
  109.                 else if (CompMoveInt == 2)
  110.                 {
  111.                     Console.WriteLine("You Lose!");
  112.                     UserMoveStr = Console.ReadLine();
  113.                     Comp = Comp + 1;
  114.                     Loss = Loss + 1;
  115.                 }
  116.                 else if (CompMoveInt == 3)
  117.                 {
  118.                     Console.WriteLine("You Win!");
  119.                     UserMoveStr = Console.ReadLine();
  120.                     Score = Score + 1;
  121.                     Wins = Wins + 1;
  122.                 }
  123.             }
  124.             else if (UserMoveInt == 2)
  125.             {
  126.                 if (CompMoveInt == 1)
  127.                 {
  128.                     Console.WriteLine("You Win!");
  129.                     UserMoveStr = Console.ReadLine();
  130.                     Score = Score + 1;
  131.                     Wins = Wins + 1;
  132.                 }
  133.                 else if (CompMoveInt == 2)
  134.                 {
  135.                     Console.WriteLine("Tie!");
  136.                     UserMoveStr = Console.ReadLine();
  137.                     Ties = Ties + 1;
  138.                 }
  139.                 else if (CompMoveInt == 3)
  140.                 {
  141.                     Console.WriteLine("You Lose!");
  142.                     UserMoveStr = Console.ReadLine();
  143.                     Comp = Comp + 1;
  144.                     Loss = Loss + 1;
  145.                 }
  146.             }
  147.             else if (UserMoveInt == 3)
  148.             {
  149.                 if (CompMoveInt == 1)
  150.                 {
  151.                     Console.WriteLine("You Lose!");
  152.                     UserMoveStr = Console.ReadLine();
  153.                     Comp = Comp + 1;
  154.                     Loss = Loss + 1;
  155.                 }
  156.                 else if (CompMoveInt == 2)
  157.                 {
  158.                     Console.WriteLine("You Win!");
  159.                     UserMoveStr = Console.ReadLine();
  160.                     Score = Score + 1;
  161.                     Wins = Wins + 1;
  162.                 }
  163.                 else if (CompMoveInt == 3)
  164.                 {
  165.                     Console.WriteLine("Tie!");
  166.                     UserMoveStr = Console.ReadLine();
  167.                     Ties = Ties + 1;
  168.                 }
  169.             }
  170.             if (Comp > Score)
  171.             {
  172.                 PlayStat = "Losing!";
  173.             }
  174.             if (Comp < Score)
  175.             {
  176.                 PlayStat = "Winning!";
  177.             }
  178.             if (Comp == Score)
  179.             {
  180.                 PlayStat = "Tied!";
  181.             }
  182.             Console.Clear();
  183.             goto Start;
  184.         }
  185.     }
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement