Advertisement
fagylalt

Untitled

Jan 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.73 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 kopapirollo
  8. {
  9.     class Program
  10.  
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.  
  15.             Random veletlen = new Random();
  16.             string[] lehetosegek = { "kő", "papír", "olló" };
  17.             int jatekospont = 0;
  18.             int geppont = 0;
  19.             Start:
  20.             Console.WriteLine("Mit választasz? (kő, papír, olló)");
  21.             if (geppont == 3 || jatekospont == 3)
  22.             {
  23.                 if (geppont == 3)
  24.                 {
  25.                     Console.WriteLine("A gép nyert");
  26.                     Console.ReadKey();
  27.                     Environment.Exit(0);
  28.  
  29.  
  30.                 }
  31.  
  32.                 if (jatekospont == 3)
  33.                 {
  34.                     Console.WriteLine("A játékos nyert");
  35.                     Console.ReadKey();
  36.                     Environment.Exit(0);
  37.  
  38.                 }
  39.             }
  40.             string megadott = Console.ReadLine();
  41.  
  42.             if (megadott != lehetosegek[0] && megadott != lehetosegek[1] && megadott != lehetosegek[2])
  43.             {
  44.                 Console.WriteLine("Rossz értéket adott meg!");
  45.                 goto Start;
  46.             }
  47.            
  48.  
  49.             while (true)
  50.  
  51.             {
  52.  
  53.  
  54.  
  55.                 int haromkozul = veletlen.Next(0, 2);
  56.  
  57.                 switch (megadott)
  58.                 {
  59.                     case "kő":
  60.                         {
  61.                             if (haromkozul == 0)
  62.                             {
  63.                                 Console.WriteLine("Döntetlen");
  64.  
  65.                             }
  66.                             if (haromkozul == 1)
  67.                             {
  68.                                 Console.WriteLine("Vesztettél");
  69.  
  70.                                 geppont++;
  71.                             }
  72.                             if (haromkozul == 2)
  73.                             {
  74.                                 Console.WriteLine("Nyertél");
  75.  
  76.                                 jatekospont++;
  77.                             }
  78.                             goto Start;
  79.                         }
  80.                     case "papír":
  81.                         {
  82.                             if (haromkozul == 0)
  83.                             {
  84.                                 Console.WriteLine("Nyertél");
  85.  
  86.                                 jatekospont++;
  87.                             }
  88.                             if (haromkozul == 1)
  89.                             {
  90.                                 Console.WriteLine("Döntetlen");
  91.  
  92.                             }
  93.                             if (haromkozul == 2)
  94.                             {
  95.                                 Console.WriteLine("Vesztettél");
  96.                                 geppont++;
  97.                             }
  98.                             goto Start;
  99.                         }
  100.                     case "olló":
  101.                         {
  102.                             if (haromkozul == 0)
  103.                             {
  104.                                 Console.WriteLine("Vesztettél");
  105.                                 geppont++;
  106.                             }
  107.                             if (haromkozul == 1)
  108.                             {
  109.                                 Console.WriteLine("Nyertél");
  110.  
  111.                                 jatekospont++;
  112.                             }
  113.                             if (haromkozul == 2)
  114.                             {
  115.                                 Console.WriteLine("Döntetlen");
  116.  
  117.                             }
  118.                             goto Start;
  119.  
  120.                         }
  121.                 }
  122.  
  123.  
  124.  
  125.             }
  126.  
  127.         }
  128.     }
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement