Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.77 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Lab2
  4. {
  5.     class Program
  6.     {
  7.         static void Pytanie(string pytanie, int nrPytania)
  8.         {
  9.             Console.WriteLine($"-> Pytanie nr. {nrPytania}: {pytanie}?");            
  10.         }
  11.  
  12.         static bool Odpowiedz()
  13.         {
  14.             return bool.Parse(Console.ReadLine());
  15.         }
  16.  
  17.         static void wynik(string[] pytania, bool[] odpowiedzi)
  18.         {
  19.             Console.WriteLine("----TWOJE ODPOWIEDZI----");
  20.             Console.WriteLine("");
  21.             for (int i = 0; i < pytania.Length; i++)
  22.             {
  23.                 Console.WriteLine($"{pytania[i]}? - {odpowiedzi[i]}");
  24.             }
  25.         }
  26.  
  27.         static void Main()
  28.         {
  29.             Console.Write("WPISZ IMIĘ: ");
  30.             var imie = Console.ReadLine();
  31.             Console.Clear();
  32.             Console.WriteLine($"----Witaj, {imie}, odowiedz na pytania: true/false----");
  33.             Console.WriteLine("");
  34.             var suma = 0;
  35.             var odpowiedzi = new bool[10];
  36.  
  37.             var pytania = new string[] {
  38.                 "Czy jesteś studentem Politechnik Opolskiej",
  39.                 "Czy studiujesz informatyke",
  40.                 "Czy programowałeś wcześniej w C#",
  41.                 "Czy znasz polecenia SQL",
  42.                 "Czy potrafisz rozwiązywać trudne zadania matematyczne",
  43.                 "Czy lubisz dużo jeść",
  44.                 "Czy lubisz placki",
  45.                 "Czy aktywnie spędzasz czas wolny",
  46.                 "Czy masz prawo jazdy",
  47.                 "Czy masz problem z alkoholem"
  48.             };
  49.  
  50.             try
  51.             {
  52.                 for (int i = 0; i < pytania.Length; i++)
  53.                 {
  54.                     Pytanie(pytania[i], i);
  55.                     odpowiedzi[i] = Odpowiedz();
  56.                 }
  57.             }
  58.             catch(Exception exception)
  59.             {
  60.                 Console.WriteLine("");
  61.                 Console.WriteLine($"@@@ BŁĄD (program zostanie zrestartowany): {exception.Message}");
  62.                 Console.WriteLine("");
  63.                 Console.ReadKey();
  64.                 Console.Clear();
  65.                 Main();
  66.             }
  67.  
  68.             Console.Clear();
  69.             wynik(pytania, odpowiedzi);
  70.  
  71.             for (int i = 0; i < 5; i++)
  72.             {
  73.                 if (odpowiedzi[i])
  74.                 {
  75.                     suma++;
  76.                 }
  77.             }
  78.  
  79.             Console.WriteLine("");
  80.             Console.WriteLine("");
  81.  
  82.             if (suma == 5)
  83.             {
  84.                 Console.WriteLine($"Witaj {imie} na pokładzie !!!");
  85.             }
  86.             else
  87.             {
  88.                 Console.WriteLine("Niestety, Twoje umiejętności są nie wystarczające na to stanowisko.");
  89.             }
  90.  
  91.  
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement