Cassimus

clickon

Aug 30th, 2025
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class Program
  5. {
  6. static void Main()
  7. {
  8. // Lista haseE
  9. List<string> hasla = new List<string> {
  10. "Minecraft",
  11. "Roblox",
  12. "Among Us",
  13. "Mario Kart",
  14. "Pokemon",
  15. "Animal Crossing",
  16. "Beat Saber",
  17. "Just Dance"
  18. };
  19.  
  20. //Losowanie hasEa
  21. Random maszynaLosujaca = new Random();
  22. int wylosowana = maszynaLosujaca.Next(0, hasla.Count);
  23.  
  24. string haslo = hasla[wylosowana].ToLower();
  25.  
  26.  
  27. int pozostaleSzanse = 5;
  28. bool wygrana = false;
  29.  
  30. List<char> uzyteLitery = new List<char>();
  31.  
  32. while (pozostaleSzanse > 0 && !wygrana)
  33. {
  34. wygrana = true;
  35. foreach (char znak in haslo)
  36. {
  37. if (znak == ' ' || uzyteLitery.Contains(znak))
  38. Console.Write(znak + " ");
  39. else
  40. {
  41. Console.Write("_ ");
  42. wygrana = false;
  43. }
  44. }
  45. Console.WriteLine();
  46.  
  47. if(wygrana) break;
  48.  
  49. Console.WriteLine("Uzyte litery: ");
  50. Console.WriteLine(string.Join(", ", uzyteLitery));
  51. Console.WriteLine("Pozostale szanse: " + pozostaleSzanse);
  52.  
  53. // pobranie litery od gracza
  54. Console.WriteLine("Podaj litere: ");
  55. char litera = Console.ReadLine().ToLower()[0];
  56. Console.Clear();
  57.  
  58. if(uzyteLitery.Contains(litera))
  59. {
  60. Console.WriteLine("Ta litera byla uzyta");
  61. continue;
  62. }
  63.  
  64. uzyteLitery.Add(litera);
  65. if(!haslo.Contains(litera))
  66. pozostaleSzanse--;
  67.  
  68. }
  69.  
  70.  
  71. if(wygrana)
  72. Console.WriteLine("Wygrana! Haslo to " + haslo);
  73. else
  74. Console.WriteLine("Przegrana. Haslo to " + haslo);
  75.  
  76. }
  77. }
  78.  
  79.  
Advertisement
Add Comment
Please, Sign In to add comment