diff --git a/main.typ b/main.typ index c837284..9899631 100644 --- a/main.typ +++ b/main.typ @@ -303,30 +303,31 @@ Jest jeszcze pętla `foreach`, która w róznych jezykach ma rózna składnię, ==== Przykład ```cs Console.WriteLine("Let's count to 10."); -for (int i = 0; i < 10; i++;) +for (int i = 0; i < 10; i++) { - Console.WriteLine(i + 1); + Console.WriteLine(i + 1); } bool shouldQuit = false; -while (shouldQuit) { - Console.WriteLine("I will run until you type 'q'.") - char response = Console.ReadLine(); - if (response == 'q') { - shouldQuit = true; - } +while (!shouldQuit) +{ + Console.WriteLine("I will run until you type 'q'."); + string response = Console.ReadLine(); + if (response == "q") { + shouldQuit = true; + } } string correctPin = "1234"; string enteredPin = ""; do { - Console.Write("Please provide your PIN: "); - enteredPin = Console.ReadLine(); + Console.Write("Please provide your PIN: "); + enteredPin = Console.ReadLine(); - if (enteredPin != correctPin) { - Console.WriteLine("Incorrect PIN. Try again"); - } + if (enteredPin != correctPin) { + Console.WriteLine("Incorrect PIN. Try again"); + } } while (enteredPin != correctPin); Console.WriteLine("Correct PIN! Access granted."); @@ -334,10 +335,40 @@ Console.WriteLine("Correct PIN! Access granted."); string[] shoppingList = new string[] { "bread", "chicken", "butter"}; Console.WriteLine("Your shopping list:"); foreach (string product in shoppingList) { - Console.WriteLine($"- {product}"); + Console.WriteLine($"- {product}"); } ``` ==== Rezultat +Wynik działania powyższego kodu to: +``` +Let's count to 10. +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +I will run until you type 'q'. +asdsd +I will run until you type 'q'. +cvcv +I will run until you type 'q'. +asas +I will run until you type 'q'. +q +Please provide your PIN: 123 +Incorrect PIN. Try again +Please provide your PIN: 1234 +Correct PIN! Access granted. +Your shopping list: +- bread +- chicken +- butter +``` ==== Wyjaśnienie ==== Ćwiczenia === Instrukcje skoku