Advertisement
Guest User

Untitled

a guest
Oct 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp4
  8. {
  9.     class Program
  10.     {
  11.         public static List<String> options = new List<String>() { "Stone", "Paper", "Scissors", "Spock", "Lizard", "Uncknow1", "Uncknow2", "Uncknow3", "Uncknow4" };
  12.         public static List<String> results = new List<String>();
  13.         static public int Mod(int a, int b)
  14.         {
  15.             if (a >= 0) return a % b;
  16.             else return b - a % b;
  17.         }
  18.  
  19.         static void Main(string[] args)
  20.         {
  21.             int range, playerChoice = -1, act = 0;
  22.             Console.WriteLine("Enter number of move: ");
  23.             while (!int.TryParse(Console.ReadLine(),out range)
  24.                 || (range < 3 || range > options.Count || range % 2 == 0))
  25.                 Console.WriteLine("Error. Print again!");
  26.  
  27.             while(playerChoice != 0)
  28.             {
  29.                 Random random = new Random();
  30.                 int compChoice = random.Next(0, options.Capacity - 1);
  31.                 while (!int.TryParse(Console.ReadLine(), out playerChoice)
  32.                 || (playerChoice < 0 || playerChoice > range))
  33.                     Console.WriteLine("Error. Print again!");
  34.                 if (Mod((playerChoice - 1) - compChoice, options.Capacity) == 0) results.Add("act " + ++act + ": " + "Draw.");
  35.                 if (Mod((playerChoice - 1) - compChoice, options.Capacity) % 2 == 1) results.Add("act " + ++act + ": " + "Win.");
  36.                 else results.Add("act " + ++act + ": " + "Lose.");
  37.             }
  38.             results.ForEach(x => Console.WriteLine(x));
  39.             Console.ReadLine();
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement