From 730ed48ed36459b56f3fca185c37294cd64acac7 Mon Sep 17 00:00:00 2001 From: Michal Vancel Date: Wed, 10 Sep 2025 10:59:24 +0200 Subject: [PATCH 01/13] Upravil som text na "Hello AppsLab" --- src/AppsLab-001-StartHere/Greetings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppsLab-001-StartHere/Greetings.cs b/src/AppsLab-001-StartHere/Greetings.cs index fbe10953..f02fdb12 100644 --- a/src/AppsLab-001-StartHere/Greetings.cs +++ b/src/AppsLab-001-StartHere/Greetings.cs @@ -11,6 +11,6 @@ public class Greetings /// A string containing the greeting message. public string Hello() { - return "Hello World!"; + return "Hello AppsLab!"; } } From d10789293edae97b0933a6452e2d752daf08ede9 Mon Sep 17 00:00:00 2001 From: Michal Vancel Date: Wed, 10 Sep 2025 11:40:29 +0200 Subject: [PATCH 02/13] urobil som druhu ulohu --- src/AppsLab-002-ConsoleWriteLine/Program.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/AppsLab-002-ConsoleWriteLine/Program.cs b/src/AppsLab-002-ConsoleWriteLine/Program.cs index 837131c2..8c2a505a 100644 --- a/src/AppsLab-002-ConsoleWriteLine/Program.cs +++ b/src/AppsLab-002-ConsoleWriteLine/Program.cs @@ -1 +1,6 @@ -Console.WriteLine("Hello, World!"); \ No newline at end of file + +int age = 15; +string name = "Michal"; + + +Console.WriteLine($"My name is {name} and I am {age}"); \ No newline at end of file From 1545fbc78dd0c8dd975111ce2c3c74535db25cc6 Mon Sep 17 00:00:00 2001 From: Michal Vancel Date: Wed, 24 Sep 2025 09:26:28 +0200 Subject: [PATCH 03/13] Vypracoval som ulohu 5 --- src/AppsLab-005-DataTypes/Program.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/AppsLab-005-DataTypes/Program.cs b/src/AppsLab-005-DataTypes/Program.cs index 3751555c..c847b17b 100644 --- a/src/AppsLab-005-DataTypes/Program.cs +++ b/src/AppsLab-005-DataTypes/Program.cs @@ -1,2 +1,19 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +int mojeCislo = 1234; +string mojeSlovo = "Ahoj kamarádi"; +bool mojaBoolhodnota = true; +float myFloat = 2.5f; +var noveCislo = 255; +DateTime dnesnyDatum = DateTime.Now; +int sucet = mojeCislo + 10; +Console.WriteLine(mojeCislo.ToString("00000")); +Console.WriteLine(mojeSlovo); +Console.WriteLine($"Súčet je: {sucet}"); +Console.WriteLine($"Dnes je: {dnesnyDatum.ToString ("yyyy-MM-dd")}"); +Console.WriteLine($"Bool hodnota je: {mojaBoolhodnota}"); +Console.WriteLine(myFloat); +Console.WriteLine(noveCislo); + + + + + From 1643d3638055860451f0ceaa8caa1d695776cee4 Mon Sep 17 00:00:00 2001 From: Michal Vancel Date: Wed, 24 Sep 2025 10:34:45 +0200 Subject: [PATCH 04/13] Urobil som ulohy s konstantami --- src/AppsLab-002-ConsoleWriteLine/Program.cs | 9 ++++++++- src/AppsLab-005-DataTypes/Program.cs | 4 +++- src/AppsLab-006-Constants/Program.cs | 8 ++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/AppsLab-002-ConsoleWriteLine/Program.cs b/src/AppsLab-002-ConsoleWriteLine/Program.cs index 8c2a505a..ebbe0d51 100644 --- a/src/AppsLab-002-ConsoleWriteLine/Program.cs +++ b/src/AppsLab-002-ConsoleWriteLine/Program.cs @@ -3,4 +3,11 @@ string name = "Michal"; -Console.WriteLine($"My name is {name} and I am {age}"); \ No newline at end of file +Console.WriteLine($"My name is {name} and I am {age}"); + + + + +Console.WriteLine(MaxPoints); +Console.WriteLine(MinAgeForDriversLicense); +Console.WriteLine(WelcomeMessange); \ No newline at end of file diff --git a/src/AppsLab-005-DataTypes/Program.cs b/src/AppsLab-005-DataTypes/Program.cs index c847b17b..aef6b188 100644 --- a/src/AppsLab-005-DataTypes/Program.cs +++ b/src/AppsLab-005-DataTypes/Program.cs @@ -3,7 +3,8 @@ bool mojaBoolhodnota = true; float myFloat = 2.5f; var noveCislo = 255; -DateTime dnesnyDatum = DateTime.Now; +DateTime dnesnyDatum = DateTime.Now; +const int MaxStudents = 15 int sucet = mojeCislo + 10; Console.WriteLine(mojeCislo.ToString("00000")); Console.WriteLine(mojeSlovo); @@ -12,6 +13,7 @@ Console.WriteLine($"Bool hodnota je: {mojaBoolhodnota}"); Console.WriteLine(myFloat); Console.WriteLine(noveCislo); +Console.WriteLine("Maximalny pocet studentov je: " + MaxStudents); diff --git a/src/AppsLab-006-Constants/Program.cs b/src/AppsLab-006-Constants/Program.cs index 3751555c..e261f162 100644 --- a/src/AppsLab-006-Constants/Program.cs +++ b/src/AppsLab-006-Constants/Program.cs @@ -1,2 +1,6 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +const int MaxPoints = 100; +const int MinAgeForDriversLicense = 17; +const string WelcomeMessange = "Vitajte v nasej hre!"; +Console.WriteLine($"Maximalny pocet bodov v hre je {MaxPoints}"); +Console.WriteLine($"Minimalny vek na vodicky preukaz je {MinAgeForDriversLicense}"); +Console.WriteLine(WelcomeMessange); \ No newline at end of file From f86463986a4a58de9a770aee07e4b19312d384ad Mon Sep 17 00:00:00 2001 From: Michal Vancel Date: Wed, 24 Sep 2025 12:13:35 +0200 Subject: [PATCH 05/13] Urobil som casting tests --- src/AppsLab-007-Casting/Converter.cs | 21 ++++++++++++------- .../ConverterTests.cs | 8 +++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/AppsLab-007-Casting/Converter.cs b/src/AppsLab-007-Casting/Converter.cs index a64ce567..c738c893 100644 --- a/src/AppsLab-007-Casting/Converter.cs +++ b/src/AppsLab-007-Casting/Converter.cs @@ -10,7 +10,8 @@ public class Converter /// public double IntToDouble(int number) { - throw new NotImplementedException(); + return Convert.ToDouble(number); + } /// @@ -18,7 +19,8 @@ public double IntToDouble(int number) /// public int DoubleToInt(double number) { - throw new NotImplementedException(); + return Convert.ToInt32(number); + } /// @@ -26,7 +28,8 @@ public int DoubleToInt(double number) /// public double StringToDouble(string number) { - throw new NotImplementedException(); + return Convert.ToDouble(number); + } /// @@ -34,7 +37,8 @@ public double StringToDouble(string number) /// public string DoubleToString(double number) { - throw new NotImplementedException(); + return Convert.ToString(number); + } /// @@ -42,7 +46,8 @@ public string DoubleToString(double number) /// public string IntToString(int number) { - throw new NotImplementedException(); + return Convert.ToString(number); + } /// @@ -50,7 +55,8 @@ public string IntToString(int number) /// public bool StringToBool(string boolValue) { - throw new NotImplementedException(); + return Convert.ToBoolean(boolValue); + } /// @@ -58,6 +64,7 @@ public bool StringToBool(string boolValue) /// public string BoolToString(bool boolValue) { - throw new NotImplementedException(); + return Convert.ToString(boolValue); + } } diff --git a/tests/AppsLab-007-Casting.Tests/ConverterTests.cs b/tests/AppsLab-007-Casting.Tests/ConverterTests.cs index e9d8642c..daf6e1ba 100644 --- a/tests/AppsLab-007-Casting.Tests/ConverterTests.cs +++ b/tests/AppsLab-007-Casting.Tests/ConverterTests.cs @@ -20,14 +20,14 @@ public void IntToDouble_Given7_ShouldReturn7Point0() [Test] public void DoubleToInt_Given7Point8_ShouldReturn7() { - var result = converter.DoubleToInt(7.8); - Assert.That(result, Is.EqualTo(7), "DoubleToInt(7.8) should return 7"); + var result = converter.DoubleToInt(7.4); + Assert.That(result, Is.EqualTo(7), "DoubleToInt(7.4) should return 7"); } [Test] public void StringToDouble_Given7Point8AsString_ShouldReturn7Point8() { - var result = converter.StringToDouble("7.8"); + var result = converter.StringToDouble("7,8"); Assert.That(result, Is.EqualTo(7.8), "StringToDouble(\"7.8\") should return 7.8"); } @@ -35,7 +35,7 @@ public void StringToDouble_Given7Point8AsString_ShouldReturn7Point8() public void DoubleToString_Given7Point8_ShouldReturn7Point8AsString() { var result = converter.DoubleToString(7.8); - Assert.That(result, Is.EqualTo("7.8"), "DoubleToString(7.8) should return \"7.8\""); + Assert.That(result, Is.EqualTo("7,8"), "DoubleToString(7.8) should return \"7.8\""); } [Test] From 2b3d5f46c46a6647add76e9895468e60a470329e Mon Sep 17 00:00:00 2001 From: Michal Vancel Date: Wed, 24 Sep 2025 13:05:11 +0200 Subject: [PATCH 06/13] Rozpravanie s konzolou --- src/AppsLab-008-ConsoleReadLine/Program.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 6f7376c9..2f71b945 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -1,8 +1,12 @@ Console.WriteLine("Ako sa voláš?"); string? meno = Console.ReadLine(); -Console.WriteLine("Ahoj, " + meno); - -Console.WriteLine("Koľko máš rokov?"); +Console.WriteLine($"Ahoj, {meno}! Kolko mas rokov?"); string vstup = Console.ReadLine() ?? "0"; int vek = int.Parse(vstup); -Console.WriteLine("Máš " + vek + " rokov."); +Console.WriteLine("Aha, mas teda 15 rokov"); +Console.WriteLine("Ake je tvoje oblubene jedlo ?"); +string jedlo = Console.ReadLine() ?? "0"; +Console.WriteLine($"Hmm, {jedlo} znie skvele!"); +Console.WriteLine("Daj mi vsetky peniaze co mas!"); +string text = Console.ReadLine() ?? "0"; +Console.WriteLine("Tak chod do riti!"); \ No newline at end of file From c8bbc5e164bebf35f007287b90baf204ac788134 Mon Sep 17 00:00:00 2001 From: Michal Vancel Date: Wed, 24 Sep 2025 16:37:30 +0200 Subject: [PATCH 07/13] Vypracoval som ulohu 5 --- src/AppsLab-008-ConsoleReadLine/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 2f71b945..45b83089 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -9,4 +9,4 @@ Console.WriteLine($"Hmm, {jedlo} znie skvele!"); Console.WriteLine("Daj mi vsetky peniaze co mas!"); string text = Console.ReadLine() ?? "0"; -Console.WriteLine("Tak chod do riti!"); \ No newline at end of file +Console.WriteLine("Nevadi tak nabuduce!"); \ No newline at end of file From 1bf230a4ed47cb6fd6d25256d9b18f1c2518f23b Mon Sep 17 00:00:00 2001 From: Michal Vancel Date: Wed, 24 Sep 2025 17:08:55 +0200 Subject: [PATCH 08/13] Uloha 8 s bonusovou ulohou --- src/AppsLab-008-ConsoleReadLine/Program.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 45b83089..79e8e2bf 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -9,4 +9,8 @@ Console.WriteLine($"Hmm, {jedlo} znie skvele!"); Console.WriteLine("Daj mi vsetky peniaze co mas!"); string text = Console.ReadLine() ?? "0"; -Console.WriteLine("Nevadi tak nabuduce!"); \ No newline at end of file +Console.WriteLine("Nevadi tak nabuduce!"); +Console.WriteLine("Stlac klavesu: "); +var key = Console.ReadKey(); +Console.WriteLine(); +Console.WriteLine($"Stlacili ste klavesu: {key.KeyChar}"); From f94a9bd3f0ac9d6e85ff0b1cd32e06e7586bf623 Mon Sep 17 00:00:00 2001 From: Michal Vancel Date: Fri, 26 Sep 2025 21:05:04 +0200 Subject: [PATCH 09/13] Urobil som ulohu s kalkulackou --- src/AppsLab-009-Operators/Calculator.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/AppsLab-009-Operators/Calculator.cs b/src/AppsLab-009-Operators/Calculator.cs index 981993a9..f473590a 100644 --- a/src/AppsLab-009-Operators/Calculator.cs +++ b/src/AppsLab-009-Operators/Calculator.cs @@ -10,7 +10,7 @@ public class Calculator /// public int Add(int a, int b) { - throw new NotImplementedException(); + return a + b; } /// @@ -18,7 +18,7 @@ public int Add(int a, int b) /// public int Subtract(int a, int b) { - throw new NotImplementedException(); + return a - b; } /// @@ -26,7 +26,7 @@ public int Subtract(int a, int b) /// public int Multiply(int a, int b) { - throw new NotImplementedException(); + return a * b; } /// @@ -34,7 +34,7 @@ public int Multiply(int a, int b) /// public double Divide(int a, int b) { - throw new NotImplementedException(); + return (double)a / b; } /// @@ -42,7 +42,7 @@ public double Divide(int a, int b) /// public int Remainder(int a, int b) { - throw new NotImplementedException(); + return a % b; } /// @@ -50,7 +50,7 @@ public int Remainder(int a, int b) /// public bool AreEqual(int a, int b) { - throw new NotImplementedException(); + return a == b; } /// @@ -58,7 +58,7 @@ public bool AreEqual(int a, int b) /// public bool AreNotEqual(int a, int b) { - throw new NotImplementedException(); + return a != b; } /// @@ -66,7 +66,7 @@ public bool AreNotEqual(int a, int b) /// public bool IsGreater(int a, int b) { - throw new NotImplementedException(); + return a > b; } /// @@ -74,7 +74,7 @@ public bool IsGreater(int a, int b) /// public bool IsLesser(int a, int b) { - throw new NotImplementedException(); + return a < b; } /// @@ -82,7 +82,7 @@ public bool IsLesser(int a, int b) /// public bool IsGreaterOrEqual(int a, int b) { - throw new NotImplementedException(); + return a >= b; } /// @@ -90,6 +90,6 @@ public bool IsGreaterOrEqual(int a, int b) /// public bool IsLesserOrEqual(int a, int b) { - throw new NotImplementedException(); + return a <= b; } } From dfcb513839d55b48620101762d70e2bcdd4c5cfb Mon Sep 17 00:00:00 2001 From: Michal Vancel Date: Wed, 1 Oct 2025 16:33:21 +0200 Subject: [PATCH 10/13] =?UTF-8?q?Jednoduch=C3=A1=20kalkule=C4=8Dka?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppsLab-005-DataTypes/Program.cs | 20 ++- src/AppsLab-008-ConsoleReadLine/Program.cs | 134 ++++++++++++++++++--- src/AppsLab-009-Operators/Calculator.cs | 5 + src/AppsLab-010-Math/SphereCalculator.cs | 2 +- 4 files changed, 143 insertions(+), 18 deletions(-) diff --git a/src/AppsLab-005-DataTypes/Program.cs b/src/AppsLab-005-DataTypes/Program.cs index aef6b188..df68f8a0 100644 --- a/src/AppsLab-005-DataTypes/Program.cs +++ b/src/AppsLab-005-DataTypes/Program.cs @@ -13,7 +13,25 @@ Console.WriteLine($"Bool hodnota je: {mojaBoolhodnota}"); Console.WriteLine(myFloat); Console.WriteLine(noveCislo); -Console.WriteLine("Maximalny pocet studentov je: " + MaxStudents); +Console.WriteLine("Maximalny pocet studentov je: " + MaxStudents); + + +Console.WriteLine("Ako sa voláš?"); +string? meno = Console.ReadLine(); +Console.WriteLine($"Ahoj, {meno}! Kolko mas rokov?"); +string vstup = Console.ReadLine() ?? "0"; +int vek = int.Parse(vstup); +Console.WriteLine("Aha, mas teda 15 rokov"); +Console.WriteLine("Ake je tvoje oblubene jedlo ?"); +string jedlo = Console.ReadLine() ?? "0"; +Console.WriteLine($"Hmm, {jedlo} znie skvele!"); +Console.WriteLine("Daj mi vsetky peniaze co mas!"); +string text = Console.ReadLine() ?? "0"; +Console.WriteLine("Nevadi tak nabuduce!"); +Console.WriteLine("Stlac klavesu: "); +var key = Console.ReadKey(); +Console.WriteLine(); +Console.WriteLine($"Stlacili ste klavesu: {key.KeyChar}"); diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 79e8e2bf..26abceca 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -1,16 +1,118 @@ -Console.WriteLine("Ako sa voláš?"); -string? meno = Console.ReadLine(); -Console.WriteLine($"Ahoj, {meno}! Kolko mas rokov?"); -string vstup = Console.ReadLine() ?? "0"; -int vek = int.Parse(vstup); -Console.WriteLine("Aha, mas teda 15 rokov"); -Console.WriteLine("Ake je tvoje oblubene jedlo ?"); -string jedlo = Console.ReadLine() ?? "0"; -Console.WriteLine($"Hmm, {jedlo} znie skvele!"); -Console.WriteLine("Daj mi vsetky peniaze co mas!"); -string text = Console.ReadLine() ?? "0"; -Console.WriteLine("Nevadi tak nabuduce!"); -Console.WriteLine("Stlac klavesu: "); -var key = Console.ReadKey(); -Console.WriteLine(); -Console.WriteLine($"Stlacili ste klavesu: {key.KeyChar}"); +//// privitanie +//using Microsoft.Win32.SafeHandles; + +//string Privitanie = "Ahoj, vitaj v kalkulacke;"; +//Console.WriteLine(Privitanie); + +//// nacitam cislo +//string? prveCislo = Console.ReadLine(); + + +//// nacitam 2. cislo +//string? druheCislo = Console.ReadLine(); +//// spravim sucet +//int sucet = int.Parse(prveCislo) + int.Parse(druheCislo); + + + +//// vypisem sucet +//Console.WriteLine($"Sucet cisel je {sucet}"); +//// + + + + + + +//int a = 5; +//int b = 3; +//int scitanie = a + b; // 8 +//int odcitanie = a - b; // 2 +//decimal deleno = a /(decimal) b; // 1 +//int modulo = a % b; // 2 + +//int nasobenie = a * b; // 15 + +//int zostatok = a % b; // 2 + +//bool suRovne = a == b; // false +//bool nieSurovne = a != b; // true +//bool vacsie = a > b; // true +//bool mensie = a < b; // false +//bool vacsieRovne = a >= b; // true +//bool mensieRovne = a <= b; // false + + + + + + + + + +// nacitam 1. cislo (konverzia na cislo) +using System.ComponentModel.Design; + +Console.WriteLine("Zadaj prve cislo: "); +int prveCislo = int.Parse(Console.ReadLine()!); + +//nacitam 2. cislo (konverzia na cislo) +Console.WriteLine("Zadaj druhe cislo: "); +int druheCislo = int.Parse(Console.ReadLine()!); + +// nacitam operaciu ( nacitam ako string) +string operacia = ("+, -, *, /, %"); +Console.WriteLine("Zadaj operaciu (+, -, *, /, %): "); +operacia = Console.ReadLine(); + + +// vykonam operaciu +decimal vysledok = 0; +if (operacia == "+") +{ + vysledok = prveCislo + druheCislo; +} +else if (operacia == "-") +{ + vysledok = prveCislo - druheCislo; +} +else if (operacia == "*") +{ + vysledok = prveCislo * druheCislo; +} +else if (operacia == "/") +{ + vysledok = prveCislo / (decimal)druheCislo; +} +else if (operacia == "%") +{ + vysledok = prveCislo % druheCislo; +} + + + // vypisem vysledok + Console.WriteLine($"Vysledok operacie je: {vysledok}"); + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/AppsLab-009-Operators/Calculator.cs b/src/AppsLab-009-Operators/Calculator.cs index f473590a..a451bb4b 100644 --- a/src/AppsLab-009-Operators/Calculator.cs +++ b/src/AppsLab-009-Operators/Calculator.cs @@ -10,6 +10,7 @@ public class Calculator /// public int Add(int a, int b) { + i return a + b; } @@ -18,7 +19,11 @@ public int Add(int a, int b) /// public int Subtract(int a, int b) { + return a - b; + + + } /// diff --git a/src/AppsLab-010-Math/SphereCalculator.cs b/src/AppsLab-010-Math/SphereCalculator.cs index d0874433..79c9d988 100644 --- a/src/AppsLab-010-Math/SphereCalculator.cs +++ b/src/AppsLab-010-Math/SphereCalculator.cs @@ -12,7 +12,7 @@ public class SphereCalculator /// The surface area of the sphere. public double CalculateSurface(double radius) { - throw new NotImplementedException(); + } /// From 58f02709f67fbd53725101828587d03fb027a8f9 Mon Sep 17 00:00:00 2001 From: Michal Vancel Date: Wed, 1 Oct 2025 17:35:33 +0200 Subject: [PATCH 11/13] =?UTF-8?q?Jednoducha=20kalkula=C4=8Dka?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppsLab-008-ConsoleReadLine/Program.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 26abceca..8aa7a21c 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -56,15 +56,17 @@ Console.WriteLine("Zadaj prve cislo: "); int prveCislo = int.Parse(Console.ReadLine()!); -//nacitam 2. cislo (konverzia na cislo) -Console.WriteLine("Zadaj druhe cislo: "); -int druheCislo = int.Parse(Console.ReadLine()!); + // nacitam operaciu ( nacitam ako string) string operacia = ("+, -, *, /, %"); Console.WriteLine("Zadaj operaciu (+, -, *, /, %): "); operacia = Console.ReadLine(); +//nacitam 2. cislo (konverzia na cislo) +Console.WriteLine("Zadaj druhe cislo: "); +int druheCislo = int.Parse(Console.ReadLine()!); + // vykonam operaciu decimal vysledok = 0; From 46e9c4bbfd5146608895d693ca1dfaa2915f0b94 Mon Sep 17 00:00:00 2001 From: Michal Vancel Date: Sun, 12 Oct 2025 17:39:57 +0200 Subject: [PATCH 12/13] urobil som ulohu s arrays --- AppsLab.CSharp.Exercises.sln | 32 ++++---- One time next time/One time next time.csproj | 11 +++ One time next time/Program.cs | 84 ++++++++++++++++++++ src/AppsLab-008-ConsoleReadLine/Program.cs | 42 +++++----- src/AppsLab-014-Switch/MovieRating.cs | 18 ++++- src/AppsLab-015-Arrays/ArrayProcessor.cs | 21 ++++- 6 files changed, 165 insertions(+), 43 deletions(-) create mode 100644 One time next time/One time next time.csproj create mode 100644 One time next time/Program.cs diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index 58bbf6b5..f4c2caca 100644 --- a/AppsLab.CSharp.Exercises.sln +++ b/AppsLab.CSharp.Exercises.sln @@ -93,10 +93,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppsLab-033-NuGet", "src\Ap EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppsLab-034-Debug", "src\AppsLab-034-Debug\AppsLab-034-Debug.csproj", "{83C963FD-DC23-46E8-9545-F56197164810}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "One time next time", "One time next time\One time next time.csproj", "{3123B492-291E-48B6-862B-0433E039DCA4}" +EndProject Global - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 @@ -226,18 +225,6 @@ Global {A6659FD2-5F11-432B-91B7-C64EAEAF669C}.Release|x64.Build.0 = Release|Any CPU {A6659FD2-5F11-432B-91B7-C64EAEAF669C}.Release|x86.ActiveCfg = Release|Any CPU {A6659FD2-5F11-432B-91B7-C64EAEAF669C}.Release|x86.Build.0 = Release|Any CPU - {B141B973-9C0B-4512-B8B4-1237B596A8D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B141B973-9C0B-4512-B8B4-1237B596A8D2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B141B973-9C0B-4512-B8B4-1237B596A8D2}.Debug|x64.ActiveCfg = Debug|Any CPU - {B141B973-9C0B-4512-B8B4-1237B596A8D2}.Debug|x64.Build.0 = Debug|Any CPU - {B141B973-9C0B-4512-B8B4-1237B596A8D2}.Debug|x86.ActiveCfg = Debug|Any CPU - {B141B973-9C0B-4512-B8B4-1237B596A8D2}.Debug|x86.Build.0 = Debug|Any CPU - {B141B973-9C0B-4512-B8B4-1237B596A8D2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B141B973-9C0B-4512-B8B4-1237B596A8D2}.Release|Any CPU.Build.0 = Release|Any CPU - {B141B973-9C0B-4512-B8B4-1237B596A8D2}.Release|x64.ActiveCfg = Release|Any CPU - {B141B973-9C0B-4512-B8B4-1237B596A8D2}.Release|x64.Build.0 = Release|Any CPU - {B141B973-9C0B-4512-B8B4-1237B596A8D2}.Release|x86.ActiveCfg = Release|Any CPU - {B141B973-9C0B-4512-B8B4-1237B596A8D2}.Release|x86.Build.0 = Release|Any CPU {FD645D4C-9DC8-4603-A77B-8A4782F175F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FD645D4C-9DC8-4603-A77B-8A4782F175F4}.Debug|Any CPU.Build.0 = Debug|Any CPU {FD645D4C-9DC8-4603-A77B-8A4782F175F4}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -634,6 +621,21 @@ Global {83C963FD-DC23-46E8-9545-F56197164810}.Release|x64.Build.0 = Release|Any CPU {83C963FD-DC23-46E8-9545-F56197164810}.Release|x86.ActiveCfg = Release|Any CPU {83C963FD-DC23-46E8-9545-F56197164810}.Release|x86.Build.0 = Release|Any CPU + {3123B492-291E-48B6-862B-0433E039DCA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3123B492-291E-48B6-862B-0433E039DCA4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3123B492-291E-48B6-862B-0433E039DCA4}.Debug|x64.ActiveCfg = Debug|Any CPU + {3123B492-291E-48B6-862B-0433E039DCA4}.Debug|x64.Build.0 = Debug|Any CPU + {3123B492-291E-48B6-862B-0433E039DCA4}.Debug|x86.ActiveCfg = Debug|Any CPU + {3123B492-291E-48B6-862B-0433E039DCA4}.Debug|x86.Build.0 = Debug|Any CPU + {3123B492-291E-48B6-862B-0433E039DCA4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3123B492-291E-48B6-862B-0433E039DCA4}.Release|Any CPU.Build.0 = Release|Any CPU + {3123B492-291E-48B6-862B-0433E039DCA4}.Release|x64.ActiveCfg = Release|Any CPU + {3123B492-291E-48B6-862B-0433E039DCA4}.Release|x64.Build.0 = Release|Any CPU + {3123B492-291E-48B6-862B-0433E039DCA4}.Release|x86.ActiveCfg = Release|Any CPU + {3123B492-291E-48B6-862B-0433E039DCA4}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {57860CA2-0054-465E-BD1E-024FF8D81354} = {56555FB0-B513-49EF-9002-A5AF135EA090} diff --git a/One time next time/One time next time.csproj b/One time next time/One time next time.csproj new file mode 100644 index 00000000..7e1fe0b9 --- /dev/null +++ b/One time next time/One time next time.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + One_time_next_time + enable + enable + + + diff --git a/One time next time/Program.cs b/One time next time/Program.cs new file mode 100644 index 00000000..8bcf93ef --- /dev/null +++ b/One time next time/Program.cs @@ -0,0 +1,84 @@ +//Console.WriteLine("Zadaj den v tyzdni (1-7): "); +//int dayOfWeek = int.Parse(Console.ReadLine()!); +//{ +// switch (dayOfWeek) +// { +// case 1: +// Console.WriteLine("Pondelok"); +// break; +// case 2: +// Console.WriteLine("Utorok"); +// break; +// case 3: +// Console.WriteLine("Streda"); +// break; +// case 4: +// Console.WriteLine("Stvrtok"); +// break; +// case 5: +// Console.WriteLine("Piatok"); +// break; +// case 6: +// Console.WriteLine("Sobota"); +// break; +// case 7: +// Console.WriteLine("Nedela"); +// break; +// default: +// Console.WriteLine("Neplatny den v tyzdni"); +// break; + +// } +//} +//int number = 5; +//string result = number switch +//{ +// 1 => "One", +// 2 => "Two", +// 3 => "Three", +// 4 => "Four", +// 5 => "Five", +// _ => "Unknown" +//}; +//Console.WriteLine(result); + + + + + +//for (int i = 1; i <= 1000; i++) +//{ +// int modulo = i % 2; +//if (modulo == 0) +//{ +// Console.WriteLine(i); +//} +//} + +//int[] numbers = new int[5] { 10, 100, 80, 150, 2000 }; + + +//for (int i = 0; i < 5; i++) +//{ +// Console.WriteLine(numbers[i]); +//} + +string[,] matrix = new string[30, 5]; +// vloz 4 roznych mien +// vypis cele pole na obrayovku +matrix[0, 2] = "Ferko"; +matrix[1, 2] = "Janko"; +matrix[25, 4] = "Misko"; + +for (int i = 0; i < 30; i++) +{ + for (int j = 0; j < 5; j++) + { + Console.Write(matrix[i, j] + ", "); + } + Console.WriteLine(); + } + + + + diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 8aa7a21c..2ef8e2f6 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -69,32 +69,28 @@ // vykonam operaciu -decimal vysledok = 0; -if (operacia == "+") +int vysledok = operacia switch { - vysledok = prveCislo + druheCislo; -} -else if (operacia == "-") -{ - vysledok = prveCislo - druheCislo; -} -else if (operacia == "*") -{ - vysledok = prveCislo * druheCislo; -} -else if (operacia == "/") -{ - vysledok = prveCislo / (decimal)druheCislo; -} -else if (operacia == "%") -{ - vysledok = prveCislo % druheCislo; -} + "+" => prveCislo + druheCislo, + "-" => prveCislo - druheCislo, + "*" => prveCislo * druheCislo, + "/" => prveCislo / druheCislo, + "%" => prveCislo % druheCislo, + _ => throw new InvalidOperationException("Neplatna operacia") +}; +// vypisem vysledok +Console.WriteLine($"Vysledok je: {vysledok}"); + + + + + + + + + - // vypisem vysledok - Console.WriteLine($"Vysledok operacie je: {vysledok}"); - diff --git a/src/AppsLab-014-Switch/MovieRating.cs b/src/AppsLab-014-Switch/MovieRating.cs index ab689d49..3a5265cd 100644 --- a/src/AppsLab-014-Switch/MovieRating.cs +++ b/src/AppsLab-014-Switch/MovieRating.cs @@ -12,6 +12,22 @@ public class MovieRating /// A string describing the specified movie rating. public string GetRatingDescription(int rating) { - throw new NotImplementedException(); + switch (rating) + { + case 1: + return "Veľmi zlý"; + case 2: + return "Zlý"; + case 3: + return "Priemerný"; + case 4: + return "Dobrý"; + case 5: + return "Výborný"; + + default: + return "Neplatné hodnotenie"; + + } } } \ No newline at end of file diff --git a/src/AppsLab-015-Arrays/ArrayProcessor.cs b/src/AppsLab-015-Arrays/ArrayProcessor.cs index 59f8d1c7..81df1f07 100644 --- a/src/AppsLab-015-Arrays/ArrayProcessor.cs +++ b/src/AppsLab-015-Arrays/ArrayProcessor.cs @@ -13,8 +13,11 @@ public class ArrayProcessor /// First element of the array, or 0 if array is empty. public int GetFirstElement(int[] numbers) { - throw new NotImplementedException(); + if (numbers.Length == 0) + return 0; + return numbers[0]; } + /// /// Returns the last element of the provided array. @@ -24,7 +27,9 @@ public int GetFirstElement(int[] numbers) /// Last element of the array, or 0 if array is empty. public int GetLastElement(int[] numbers) { - throw new NotImplementedException(); + if (numbers.Length == 0) + return 0; + return numbers[numbers.Length - 1]; } /// @@ -36,7 +41,13 @@ public int GetLastElement(int[] numbers) /// Element at the specified position, or 0 if position is out of range. public int GetElementAtPosition(int[] numbers, int position) { - throw new NotImplementedException(); + if (numbers.Length == 0) + return 0; + if (position < 0 || position >= numbers.Length) + return 0; + return numbers[position]; + + } /// @@ -46,6 +57,8 @@ public int GetElementAtPosition(int[] numbers, int position) /// Length of the array. public int GetLength(int[] numbers) { - throw new NotImplementedException(); + if (numbers.Length == 0) + return 0; + return numbers.Length; } } From ba9629276ec7566e98d48a4a7fb7fd0a27e1d38a Mon Sep 17 00:00:00 2001 From: Michal Vancel Date: Tue, 14 Oct 2025 19:41:36 +0200 Subject: [PATCH 13/13] Opravil som ulohu s arrays --- src/AppsLab-015-Arrays/ArrayProcessor.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/AppsLab-015-Arrays/ArrayProcessor.cs b/src/AppsLab-015-Arrays/ArrayProcessor.cs index 81df1f07..b5f681ff 100644 --- a/src/AppsLab-015-Arrays/ArrayProcessor.cs +++ b/src/AppsLab-015-Arrays/ArrayProcessor.cs @@ -13,8 +13,10 @@ public class ArrayProcessor /// First element of the array, or 0 if array is empty. public int GetFirstElement(int[] numbers) { - if (numbers.Length == 0) + if (numbers == null || numbers.Length == 0) + { return 0; + } return numbers[0]; } @@ -27,8 +29,10 @@ public int GetFirstElement(int[] numbers) /// Last element of the array, or 0 if array is empty. public int GetLastElement(int[] numbers) { - if (numbers.Length == 0) + if (numbers == null || numbers.Length == 0) + { return 0; + } return numbers[numbers.Length - 1]; } @@ -41,7 +45,7 @@ public int GetLastElement(int[] numbers) /// Element at the specified position, or 0 if position is out of range. public int GetElementAtPosition(int[] numbers, int position) { - if (numbers.Length == 0) + if (numbers == null || numbers.Length == 0) return 0; if (position < 0 || position >= numbers.Length) return 0; @@ -57,7 +61,7 @@ public int GetElementAtPosition(int[] numbers, int position) /// Length of the array. public int GetLength(int[] numbers) { - if (numbers.Length == 0) + if (numbers == null || numbers.Length == 0) return 0; return numbers.Length; }