Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace kopapirollo
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random veletlen = new Random();
- string[] lehetosegek = { "kő", "papír", "olló" };
- int jatekospont = 0;
- int geppont = 0;
- Start:
- Console.WriteLine("Mit választasz? (kő, papír, olló)");
- if (geppont == 3 || jatekospont == 3)
- {
- if (geppont == 3)
- {
- Console.WriteLine("A gép nyert");
- Console.ReadKey();
- Environment.Exit(0);
- }
- if (jatekospont == 3)
- {
- Console.WriteLine("A játékos nyert");
- Console.ReadKey();
- Environment.Exit(0);
- }
- }
- string megadott = Console.ReadLine();
- if (megadott != lehetosegek[0] && megadott != lehetosegek[1] && megadott != lehetosegek[2])
- {
- Console.WriteLine("Rossz értéket adott meg!");
- goto Start;
- }
- while (true)
- {
- int haromkozul = veletlen.Next(0, 2);
- switch (megadott)
- {
- case "kő":
- {
- if (haromkozul == 0)
- {
- Console.WriteLine("Döntetlen");
- }
- if (haromkozul == 1)
- {
- Console.WriteLine("Vesztettél");
- geppont++;
- }
- if (haromkozul == 2)
- {
- Console.WriteLine("Nyertél");
- jatekospont++;
- }
- goto Start;
- }
- case "papír":
- {
- if (haromkozul == 0)
- {
- Console.WriteLine("Nyertél");
- jatekospont++;
- }
- if (haromkozul == 1)
- {
- Console.WriteLine("Döntetlen");
- }
- if (haromkozul == 2)
- {
- Console.WriteLine("Vesztettél");
- geppont++;
- }
- goto Start;
- }
- case "olló":
- {
- if (haromkozul == 0)
- {
- Console.WriteLine("Vesztettél");
- geppont++;
- }
- if (haromkozul == 1)
- {
- Console.WriteLine("Nyertél");
- jatekospont++;
- }
- if (haromkozul == 2)
- {
- Console.WriteLine("Döntetlen");
- }
- goto Start;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement