Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class Program
- {
- static void Main()
- {
- // Lista haseE
- List<string> hasla = new List<string> {
- "Minecraft",
- "Roblox",
- "Among Us",
- "Mario Kart",
- "Pokemon",
- "Animal Crossing",
- "Beat Saber",
- "Just Dance"
- };
- //Losowanie hasEa
- Random maszynaLosujaca = new Random();
- int wylosowana = maszynaLosujaca.Next(0, hasla.Count);
- string haslo = hasla[wylosowana].ToLower();
- int pozostaleSzanse = 5;
- bool wygrana = false;
- List<char> uzyteLitery = new List<char>();
- while (pozostaleSzanse > 0 && !wygrana)
- {
- wygrana = true;
- foreach (char znak in haslo)
- {
- if (znak == ' ' || uzyteLitery.Contains(znak))
- Console.Write(znak + " ");
- else
- {
- Console.Write("_ ");
- wygrana = false;
- }
- }
- Console.WriteLine();
- if(wygrana) break;
- Console.WriteLine("Uzyte litery: ");
- Console.WriteLine(string.Join(", ", uzyteLitery));
- Console.WriteLine("Pozostale szanse: " + pozostaleSzanse);
- // pobranie litery od gracza
- Console.WriteLine("Podaj litere: ");
- char litera = Console.ReadLine().ToLower()[0];
- Console.Clear();
- if(uzyteLitery.Contains(litera))
- {
- Console.WriteLine("Ta litera byla uzyta");
- continue;
- }
- uzyteLitery.Add(litera);
- if(!haslo.Contains(litera))
- pozostaleSzanse--;
- }
- if(wygrana)
- Console.WriteLine("Wygrana! Haslo to " + haslo);
- else
- Console.WriteLine("Przegrana. Haslo to " + haslo);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment