Advertisement
Cassimus

Wisielec

May 27th, 2025
648
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.57 KB | None | 0 0
  1.  
  2. internal class Program
  3. {
  4.     private static void Main(string[] args)
  5.     {
  6.         string[] rysunkiWisielca = UtworzRysunkiWisielca();
  7.         string[] tablicaHasel = UtworzTabliceHasel();
  8.         string wylosowaneHaslo = WylosujHaslo(tablicaHasel);
  9.  
  10.         (string hasloDoWyswietlenia, int liczbaNieLiter) = ZakryjHaslo(wylosowaneHaslo);
  11.  
  12.         OdgadujHaslo(wylosowaneHaslo, hasloDoWyswietlenia, liczbaNieLiter, rysunkiWisielca);
  13.     }
  14.  
  15.     private static void OdgadujHaslo(string wylosowaneHaslo, string hasloDoWyswietlenia, int liczbaNieLiter, string[] rysunkiWisielca)
  16.     {
  17.         throw new NotImplementedException();
  18.     }
  19.  
  20.     private static (string hasloDoWyswietlenia, int liczbaNieLiter) ZakryjHaslo(string wylosowaneHaslo)
  21.     {
  22.         int liczbaNieLiter = 0;
  23.         string hasloDoWyswietlenia = "";
  24.  
  25.         for (int i = 0; i < wylosowaneHaslo.Length; i++)
  26.         {
  27.             char znak = wylosowaneHaslo[i];
  28.             if (char.IsLetter(znak))
  29.             {
  30.                 hasloDoWyswietlenia += '_';
  31.             }
  32.             else
  33.             {
  34.                 liczbaNieLiter++;
  35.                 hasloDoWyswietlenia += znak;
  36.             }
  37.         }
  38.  
  39.         return (hasloDoWyswietlenia, liczbaNieLiter);
  40.     }
  41.  
  42.     private static string WylosujHaslo(string[] tablicaHasel)
  43.     {
  44.         string haslo = "";
  45.         Random maszynaLosujaca = new Random();
  46.         int wylosowanaLiczba = maszynaLosujaca.Next(tablicaHasel.Length);
  47.         haslo = tablicaHasel[wylosowanaLiczba];
  48.         return haslo;
  49.     }
  50.  
  51.     static string[] UtworzTabliceHasel()
  52.     {
  53.         return new string[]{
  54.             "ANDES",
  55.             "SAHARA",
  56.             "MISSISSIPPI",
  57.             "ARCHIPELAG",
  58.             "TUNDRA",
  59.             "MONAKO",
  60.             "KILIMANDZARO",
  61.             "FIORD",
  62.             "ZWROTNIK RAKA",
  63.             "POLWYSEP IBERYJSKI"
  64.         };
  65.     }
  66.  
  67.     static string[] UtworzRysunkiWisielca()
  68.     {
  69.         return new string[]{
  70.  
  71. @"
  72.  +---+
  73.  |   |
  74.      |
  75.      |
  76.      |
  77.      |
  78. =========" ,
  79. @"
  80.  +---+
  81.  |   |
  82.  O   |
  83.      |
  84.      |
  85.      |
  86. =========" ,
  87. @"
  88.  +---+
  89.  |   |
  90.  O   |
  91.  |   |
  92.      |
  93.      |
  94. =========" ,
  95. @"
  96.  +---+
  97.  |   |
  98.  O   |
  99. /|   |
  100.      |
  101.      |
  102. =========" ,
  103. @"
  104.  +---+
  105.  |   |
  106.  O   |
  107. /|\  |
  108.      |
  109.      |
  110. =========" ,
  111. @"
  112.  +---+
  113.  |   |
  114.  O   |
  115. /|\  |
  116. /    |
  117.      |
  118. =========" ,
  119. @"
  120.  +---+
  121.  |   |
  122.  O   |
  123. /|\  |
  124. / \  |
  125.      |
  126. =========",
  127.  @"
  128.  +---+
  129.  |   |
  130.  X   |
  131. /|\  |
  132. / \  |
  133.      |
  134. ========="
  135.         };
  136.     }
  137.  
  138.  
  139.  
  140.    
  141. }
  142.  
  143.  
  144.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement