From 7f16490ef931c88c3b54828377c6fe93e0af3e29 Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Wed, 10 Sep 2025 10:41:23 +0200 Subject: [PATCH 01/20] Upravil som vypis na "Hello AppsLab!" z povodneho "Hello |World!" --- AppsLab.CSharp.Exercises.sln | 33 +++++++++++---------- src/AppsLab-001-StartHere/Greetings.cs | 2 +- src/AppsLab-002-ConsoleWriteLine/Program.cs | 8 ++++- test/Program.cs | 5 ++++ test/test.csproj | 10 +++++++ 5 files changed, 41 insertions(+), 17 deletions(-) create mode 100644 test/Program.cs create mode 100644 test/test.csproj diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index 58bbf6b5..e4886004 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}") = "test", "test\test.csproj", "{5524A60A-E442-43DC-B5D3-F12129B2B1DB}" +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 + {5524A60A-E442-43DC-B5D3-F12129B2B1DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5524A60A-E442-43DC-B5D3-F12129B2B1DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5524A60A-E442-43DC-B5D3-F12129B2B1DB}.Debug|x64.ActiveCfg = Debug|Any CPU + {5524A60A-E442-43DC-B5D3-F12129B2B1DB}.Debug|x64.Build.0 = Debug|Any CPU + {5524A60A-E442-43DC-B5D3-F12129B2B1DB}.Debug|x86.ActiveCfg = Debug|Any CPU + {5524A60A-E442-43DC-B5D3-F12129B2B1DB}.Debug|x86.Build.0 = Debug|Any CPU + {5524A60A-E442-43DC-B5D3-F12129B2B1DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5524A60A-E442-43DC-B5D3-F12129B2B1DB}.Release|Any CPU.Build.0 = Release|Any CPU + {5524A60A-E442-43DC-B5D3-F12129B2B1DB}.Release|x64.ActiveCfg = Release|Any CPU + {5524A60A-E442-43DC-B5D3-F12129B2B1DB}.Release|x64.Build.0 = Release|Any CPU + {5524A60A-E442-43DC-B5D3-F12129B2B1DB}.Release|x86.ActiveCfg = Release|Any CPU + {5524A60A-E442-43DC-B5D3-F12129B2B1DB}.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} @@ -679,5 +681,6 @@ Global {7BEA7878-B5BA-4480-BC56-2F7B836F64B9} = {56555FB0-B513-49EF-9002-A5AF135EA090} {38FFE1DF-4B49-40C1-9908-51860BCF2D3E} = {56555FB0-B513-49EF-9002-A5AF135EA090} {83C963FD-DC23-46E8-9545-F56197164810} = {56555FB0-B513-49EF-9002-A5AF135EA090} + {5524A60A-E442-43DC-B5D3-F12129B2B1DB} = {56555FB0-B513-49EF-9002-A5AF135EA090} EndGlobalSection EndGlobal 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!"; } } diff --git a/src/AppsLab-002-ConsoleWriteLine/Program.cs b/src/AppsLab-002-ConsoleWriteLine/Program.cs index 837131c2..fd4fcb43 100644 --- a/src/AppsLab-002-ConsoleWriteLine/Program.cs +++ b/src/AppsLab-002-ConsoleWriteLine/Program.cs @@ -1 +1,7 @@ -Console.WriteLine("Hello, World!"); \ No newline at end of file +Console.WriteLine("zadaj svoje meno"); +string name = Console.ReadLine(); +Console.WriteLine("zadaj svoj vek"); +int age = int.Parse(Console.ReadLine()); +Console.WriteLine("zadaj svoju vysku"); +decimal height = decimal.Parse(Console.ReadLine()); +Console.WriteLine($"ahoj tvoje meno je {name} a mas {age} rokov"); \ No newline at end of file diff --git a/test/Program.cs b/test/Program.cs new file mode 100644 index 00000000..e19ea654 --- /dev/null +++ b/test/Program.cs @@ -0,0 +1,5 @@ +Console.WriteLine("zadaj svoje meno"); +string name = Console.ReadLine(); +Console.WriteLine("zadaj svoj vek"); +int age = int.Parse(Console.ReadLine()); +Console.WriteLine($"ahoj tvoje meno je {name} a mas {age} rokov"); \ No newline at end of file diff --git a/test/test.csproj b/test/test.csproj new file mode 100644 index 00000000..fd4bd08d --- /dev/null +++ b/test/test.csproj @@ -0,0 +1,10 @@ + + + + Exe + net9.0 + enable + enable + + + From 43f904fa2376daceb4aa9ff4c2bb72d656979fc2 Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Wed, 10 Sep 2025 11:40:26 +0200 Subject: [PATCH 02/20] pridal som vek a dal som consolewriteline do jedneho riadku --- src/AppsLab-002-ConsoleWriteLine/Program.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/AppsLab-002-ConsoleWriteLine/Program.cs b/src/AppsLab-002-ConsoleWriteLine/Program.cs index fd4fcb43..b84b503a 100644 --- a/src/AppsLab-002-ConsoleWriteLine/Program.cs +++ b/src/AppsLab-002-ConsoleWriteLine/Program.cs @@ -1,7 +1,4 @@ -Console.WriteLine("zadaj svoje meno"); -string name = Console.ReadLine(); -Console.WriteLine("zadaj svoj vek"); -int age = int.Parse(Console.ReadLine()); -Console.WriteLine("zadaj svoju vysku"); -decimal height = decimal.Parse(Console.ReadLine()); -Console.WriteLine($"ahoj tvoje meno je {name} a mas {age} rokov"); \ No newline at end of file +int age = 14; +string name= "John"; + +Console.WriteLine($"Hello my name is {name} and i am {age} years old "); \ No newline at end of file From 0b59513f046a0766e5c60334d180278523769e09 Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Sat, 13 Sep 2025 13:05:05 +0200 Subject: [PATCH 03/20] =?UTF-8?q?pridan=C3=A9=20premenn=C3=A9=20r=C3=B4zny?= =?UTF-8?q?ch=20typov=20a=20ich=20vyp=C3=ADsanie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppsLab-002-ConsoleWriteLine/Program.cs | 4 ++-- src/AppsLab-005-DataTypes/Program.cs | 22 ++++++++++++++++++- .../AppsLab-008-ConsoleReadLine.csproj | 4 ++++ .../AppsLab-011-Strings.csproj | 4 ++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/AppsLab-002-ConsoleWriteLine/Program.cs b/src/AppsLab-002-ConsoleWriteLine/Program.cs index b84b503a..2ea10ec8 100644 --- a/src/AppsLab-002-ConsoleWriteLine/Program.cs +++ b/src/AppsLab-002-ConsoleWriteLine/Program.cs @@ -1,4 +1,4 @@ -int age = 14; +int age = 14; string name= "John"; -Console.WriteLine($"Hello my name is {name} and i am {age} years old "); \ No newline at end of file +Console.WriteLine($"Hello my name is {name} and i am {age} years old "); diff --git a/src/AppsLab-005-DataTypes/Program.cs b/src/AppsLab-005-DataTypes/Program.cs index 3751555c..ce8d4565 100644 --- a/src/AppsLab-005-DataTypes/Program.cs +++ b/src/AppsLab-005-DataTypes/Program.cs @@ -1,2 +1,22 @@ -// See https://aka.ms/new-console-template for more information + Console.WriteLine("Hello, World!"); +Console.WriteLine("Zadej cislo:"); +int cislo = int.Parse(Console.ReadLine()); + +string text = "zdravicko"; + +bool pravda = true; + + +DateTime cas = DateTime.Now; +var pi = 3.14; +if(cislo <30) +{ + Console.WriteLine("zadane cislo je moc male prosim zadaj cislo ktore je vacsie ako 30"); + int number = int.Parse(Console.ReadLine()); + cislo = number; + +} +Console.WriteLine ($"cislo je {cislo} text je {text} hodnota true or false je {pravda} {cas} hodnota pi je {pi} "); + + diff --git a/src/AppsLab-008-ConsoleReadLine/AppsLab-008-ConsoleReadLine.csproj b/src/AppsLab-008-ConsoleReadLine/AppsLab-008-ConsoleReadLine.csproj index 810698be..db1207a2 100644 --- a/src/AppsLab-008-ConsoleReadLine/AppsLab-008-ConsoleReadLine.csproj +++ b/src/AppsLab-008-ConsoleReadLine/AppsLab-008-ConsoleReadLine.csproj @@ -8,4 +8,8 @@ enable + + + + diff --git a/src/AppsLab-011-Strings/AppsLab-011-Strings.csproj b/src/AppsLab-011-Strings/AppsLab-011-Strings.csproj index b211a418..ebc28c42 100644 --- a/src/AppsLab-011-Strings/AppsLab-011-Strings.csproj +++ b/src/AppsLab-011-Strings/AppsLab-011-Strings.csproj @@ -7,4 +7,8 @@ enable + + + + From b5630fd05caed08a8389deb4eb2277b11e8aa309 Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Sat, 13 Sep 2025 13:13:23 +0200 Subject: [PATCH 04/20] (chatgpt poradil) --- src/AppsLab-005-DataTypes/AppsLab-005-DataTypes.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppsLab-005-DataTypes/AppsLab-005-DataTypes.csproj b/src/AppsLab-005-DataTypes/AppsLab-005-DataTypes.csproj index e1693b81..bc3ec91d 100644 --- a/src/AppsLab-005-DataTypes/AppsLab-005-DataTypes.csproj +++ b/src/AppsLab-005-DataTypes/AppsLab-005-DataTypes.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net7.0 AppsLab_005_DataTypes enable enable From 0d15279503f2fef35f6b21d45b717d8026ef684b Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Sat, 13 Sep 2025 13:23:37 +0200 Subject: [PATCH 05/20] TargetFrameework z net9.0 na 7.0 --- test/test.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test.csproj b/test/test.csproj index fd4bd08d..15a37357 100644 --- a/test/test.csproj +++ b/test/test.csproj @@ -2,8 +2,8 @@ Exe - net9.0 - enable + net7.0 + enable enable From b6c9ceb0cb6f43b8b4c6613be5f19a91cc7e1bae Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Sat, 13 Sep 2025 18:43:48 +0200 Subject: [PATCH 06/20] Pridal som konstanty "max points, Min age required for drivers license a welcome message" program ich taktiez vypise --- src/AppsLab-005-DataTypes/Program.cs | 1 + src/AppsLab-006-Constants/Program.cs | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/AppsLab-005-DataTypes/Program.cs b/src/AppsLab-005-DataTypes/Program.cs index ce8d4565..beb7e7cd 100644 --- a/src/AppsLab-005-DataTypes/Program.cs +++ b/src/AppsLab-005-DataTypes/Program.cs @@ -20,3 +20,4 @@ Console.WriteLine ($"cislo je {cislo} text je {text} hodnota true or false je {pravda} {cas} hodnota pi je {pi} "); + diff --git a/src/AppsLab-006-Constants/Program.cs b/src/AppsLab-006-Constants/Program.cs index 3751555c..c3c74c96 100644 --- a/src/AppsLab-006-Constants/Program.cs +++ b/src/AppsLab-006-Constants/Program.cs @@ -1,2 +1,7 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +const int MaxPoints = 100; +const int MinAgeForDriversLicense = 17; +const string WelcomeMessage = "Vitaj v nasej hre!"; + +Console.WriteLine(MaxPoints); +Console.WriteLine(MinAgeForDriversLicense); +Console.WriteLine(WelcomeMessage); From 014a3484c198609459aeb6b1b0d50ab73081bb67 Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Wed, 24 Sep 2025 09:26:39 +0200 Subject: [PATCH 07/20] Pridal som premenne bool,decimal, datetime,int,loat,var a nakoniec ich vypise. --- src/AppsLab-005-DataTypes/Program.cs | 33 +++++++++------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/src/AppsLab-005-DataTypes/Program.cs b/src/AppsLab-005-DataTypes/Program.cs index beb7e7cd..b01e743e 100644 --- a/src/AppsLab-005-DataTypes/Program.cs +++ b/src/AppsLab-005-DataTypes/Program.cs @@ -1,23 +1,10 @@ - -Console.WriteLine("Hello, World!"); -Console.WriteLine("Zadej cislo:"); -int cislo = int.Parse(Console.ReadLine()); - -string text = "zdravicko"; - -bool pravda = true; - - -DateTime cas = DateTime.Now; -var pi = 3.14; -if(cislo <30) -{ - Console.WriteLine("zadane cislo je moc male prosim zadaj cislo ktore je vacsie ako 30"); - int number = int.Parse(Console.ReadLine()); - cislo = number; - -} -Console.WriteLine ($"cislo je {cislo} text je {text} hodnota true or false je {pravda} {cas} hodnota pi je {pi} "); - - - +int cislo = 10; +string text = "test1"; +char znak = 'a'; +bool mojahodnota = true; +decimal test = 10.5m; +DateTime dnesnydatum = DateTime.Now; +int sucet = cislo + 67; +float desatinne = 1.23f; +var meno = "Alex"; +Console.WriteLine($"cislo JE {cislo.ToString("000")} TEXT JE {text} znak je {znak} hodnota bool je {mojahodnota} decimal je {test} dnesny datum je {dnesnydatum.ToString("yyyy-MM-dd")} sucet cisla {cislo} a 67 je : {sucet} Desatinne cislo je {desatinne} meno je {meno}"); \ No newline at end of file From 3304c6ad6e6e324bda69c15b07169a5424922331 Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Wed, 24 Sep 2025 12:12:58 +0200 Subject: [PATCH 08/20] fixed errors changed rturn convert etc --- src/AppsLab-005-DataTypes/Program.cs | 3 ++- src/AppsLab-006-Constants/Program.cs | 8 ++++---- src/AppsLab-007-Casting/Converter.cs | 14 +++++++------- tests/AppsLab-007-Casting.Tests/ConverterTests.cs | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/AppsLab-005-DataTypes/Program.cs b/src/AppsLab-005-DataTypes/Program.cs index b01e743e..f8d8bf44 100644 --- a/src/AppsLab-005-DataTypes/Program.cs +++ b/src/AppsLab-005-DataTypes/Program.cs @@ -7,4 +7,5 @@ int sucet = cislo + 67; float desatinne = 1.23f; var meno = "Alex"; -Console.WriteLine($"cislo JE {cislo.ToString("000")} TEXT JE {text} znak je {znak} hodnota bool je {mojahodnota} decimal je {test} dnesny datum je {dnesnydatum.ToString("yyyy-MM-dd")} sucet cisla {cislo} a 67 je : {sucet} Desatinne cislo je {desatinne} meno je {meno}"); \ No newline at end of file +Console.WriteLine($"cislo JE {cislo.ToString("000")} T" + + $"TEXT JE {text} znak je {znak} hodnota bool je {mojahodnota} decimal je {test} dnesny datum je {dnesnydatum.ToString("yyyy-MM-dd")} sucet cisla {cislo} a 67 je : {sucet} Desatinne cislo je {desatinne} meno je {meno}"); \ No newline at end of file diff --git a/src/AppsLab-006-Constants/Program.cs b/src/AppsLab-006-Constants/Program.cs index c3c74c96..902ad63e 100644 --- a/src/AppsLab-006-Constants/Program.cs +++ b/src/AppsLab-006-Constants/Program.cs @@ -1,7 +1,7 @@ const int MaxPoints = 100; const int MinAgeForDriversLicense = 17; const string WelcomeMessage = "Vitaj v nasej hre!"; - -Console.WriteLine(MaxPoints); -Console.WriteLine(MinAgeForDriversLicense); -Console.WriteLine(WelcomeMessage); +Console.WriteLine($"maximalny pocet bodov je {MaxPoints}"); +Console.WriteLine($"minimalny vek na vodicak je { MinAgeForDriversLicense}"); +Console.WriteLine($"welcome message je {WelcomeMessage}"); + \ No newline at end of file diff --git a/src/AppsLab-007-Casting/Converter.cs b/src/AppsLab-007-Casting/Converter.cs index a64ce567..8d9ffdd5 100644 --- a/src/AppsLab-007-Casting/Converter.cs +++ b/src/AppsLab-007-Casting/Converter.cs @@ -10,7 +10,7 @@ public class Converter /// public double IntToDouble(int number) { - throw new NotImplementedException(); + return Convert.ToDouble(number); } /// @@ -18,7 +18,7 @@ public double IntToDouble(int number) /// public int DoubleToInt(double number) { - throw new NotImplementedException(); + return Convert.ToInt32(number); } /// @@ -26,7 +26,7 @@ public int DoubleToInt(double number) /// public double StringToDouble(string number) { - throw new NotImplementedException(); + return Convert.ToDouble(number); } /// @@ -34,7 +34,7 @@ public double StringToDouble(string number) /// public string DoubleToString(double number) { - throw new NotImplementedException(); + return Convert.ToString(number); } /// @@ -42,7 +42,7 @@ public string DoubleToString(double number) /// public string IntToString(int number) { - throw new NotImplementedException(); + return Convert.ToString(number); } /// @@ -50,7 +50,7 @@ public string IntToString(int number) /// public bool StringToBool(string boolValue) { - throw new NotImplementedException(); + return Convert.ToBoolean(boolValue); } /// @@ -58,6 +58,6 @@ 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..76c5605f 100644 --- a/tests/AppsLab-007-Casting.Tests/ConverterTests.cs +++ b/tests/AppsLab-007-Casting.Tests/ConverterTests.cs @@ -20,8 +20,8 @@ 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] From a9e688547815f0e9110f7fa4832fb960da09154d Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Wed, 24 Sep 2025 12:50:11 +0200 Subject: [PATCH 09/20] opravil som chyby --- src/AppsLab-008-ConsoleReadLine/Program.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 6f7376c9..50255cbe 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -1,8 +1,6 @@ -Console.WriteLine("Ako sa voláš?"); -string? meno = Console.ReadLine(); -Console.WriteLine("Ahoj, " + meno); - -Console.WriteLine("Koľko máš rokov?"); -string vstup = Console.ReadLine() ?? "0"; -int vek = int.Parse(vstup); -Console.WriteLine("Máš " + vek + " rokov."); + +Console.WriteLine("ako sa volas?"); +string ? meno = Console.ReadLine(); +Console.WriteLine($"Ahoj {meno} Kolko mas rokov?"); +int vek = int.Parse(Console.ReadLine()); +Console.WriteLine($"AHA mas teda {vek} rokov"); From 8d12c45f8728b19f34654a2a6555026839392732 Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Wed, 24 Sep 2025 12:59:20 +0200 Subject: [PATCH 10/20] pridal som otazku --- src/AppsLab-008-ConsoleReadLine/Program.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 50255cbe..8b0e82dc 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -4,3 +4,6 @@ Console.WriteLine($"Ahoj {meno} Kolko mas rokov?"); int vek = int.Parse(Console.ReadLine()); Console.WriteLine($"AHA mas teda {vek} rokov"); +Console.WriteLine("ake je tvoje oblubene jedlo ?"); +string jedlo = Console.ReadLine(); +Console.WriteLine($" hmm {jedlo} znie skvele"); From 6e04368ad88af3606b8ddd6863965c3a31c30d8f Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Wed, 24 Sep 2025 13:03:37 +0200 Subject: [PATCH 11/20] pridal som otazku --- src/AppsLab-008-ConsoleReadLine/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 8b0e82dc..0e229472 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -7,3 +7,7 @@ Console.WriteLine("ake je tvoje oblubene jedlo ?"); string jedlo = Console.ReadLine(); Console.WriteLine($" hmm {jedlo} znie skvele"); +Console.WriteLine(" pre pokracovanie zadaj udaje od kreditky"); +int karta = int.Parse(Console.ReadLine()); + + From 2fac86f7a5319a05a221922e4a29889f1bff2e3c Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Wed, 24 Sep 2025 13:04:03 +0200 Subject: [PATCH 12/20] opraaava --- src/AppsLab-008-ConsoleReadLine/Program.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 0e229472..941e167e 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -7,7 +7,6 @@ Console.WriteLine("ake je tvoje oblubene jedlo ?"); string jedlo = Console.ReadLine(); Console.WriteLine($" hmm {jedlo} znie skvele"); -Console.WriteLine(" pre pokracovanie zadaj udaje od kreditky"); -int karta = int.Parse(Console.ReadLine()); + From 8ad432352a0cf8144ee7c5031238e66cfcbd08ce Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Wed, 24 Sep 2025 13:36:57 +0200 Subject: [PATCH 13/20] bonsova uloha --- src/AppsLab-008-ConsoleReadLine/Program.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 941e167e..1979f0d1 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -7,6 +7,15 @@ Console.WriteLine("ake je tvoje oblubene jedlo ?"); string jedlo = Console.ReadLine(); Console.WriteLine($" hmm {jedlo} znie skvele"); +Console.WriteLine("stlac klavesu :"); +var key = Console.ReadKey(); +Console.WriteLine(); +Console.WriteLine($"stlacili ste klavesu: {key.KeyChar}"); + + + + + From c441cd1a2e016026bb3bfed617ab2befc974e1c0 Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Thu, 25 Sep 2025 20:24:52 +0200 Subject: [PATCH 14/20] Opravil som kod s pouzitim return --- src/AppsLab-009-Operators/Calculator.cs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/AppsLab-009-Operators/Calculator.cs b/src/AppsLab-009-Operators/Calculator.cs index 981993a9..5379f246 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,8 @@ public int Multiply(int a, int b) /// public double Divide(int a, int b) { - throw new NotImplementedException(); + return (double)a / b; + } /// @@ -42,7 +43,7 @@ public double Divide(int a, int b) /// public int Remainder(int a, int b) { - throw new NotImplementedException(); + return a % b; } /// @@ -50,7 +51,7 @@ public int Remainder(int a, int b) /// public bool AreEqual(int a, int b) { - throw new NotImplementedException(); + return a == b; } /// @@ -58,7 +59,7 @@ public bool AreEqual(int a, int b) /// public bool AreNotEqual(int a, int b) { - throw new NotImplementedException(); + return a != b; } /// @@ -66,7 +67,7 @@ public bool AreNotEqual(int a, int b) /// public bool IsGreater(int a, int b) { - throw new NotImplementedException(); + return a > b; } /// @@ -74,7 +75,8 @@ public bool IsGreater(int a, int b) /// public bool IsLesser(int a, int b) { - throw new NotImplementedException(); + return a < b; + } /// @@ -82,7 +84,7 @@ public bool IsLesser(int a, int b) /// public bool IsGreaterOrEqual(int a, int b) { - throw new NotImplementedException(); + return a >= b; } /// @@ -90,6 +92,6 @@ public bool IsGreaterOrEqual(int a, int b) /// public bool IsLesserOrEqual(int a, int b) { - throw new NotImplementedException(); + return a <= b; } } From 7685f0c55ed85ebeceb78fd2cfc52cacfe57773e Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Thu, 25 Sep 2025 20:51:07 +0200 Subject: [PATCH 15/20] =?UTF-8?q?Pridal=20som=20v=C3=BDpo=C4=8Det=20povrch?= =?UTF-8?q?u=20a=20objemu=20gule.=20Na=20za=C4=8Diatku=20som=20tomu=20?= =?UTF-8?q?=C3=BAplne=20nerozumel,=20tak=C5=BEe=20som=20si=20pomohol=20s?= =?UTF-8?q?=20ChatGPT.=20Pod=20ka=C5=BEd=C3=BD=20return=20som=20zap=C3=ADs?= =?UTF-8?q?al=20stru=C4=8Dn=C3=BD=20koment=C3=A1r,=20ktor=C3=BD=20vysvet?= =?UTF-8?q?=C4=BEuje,=20=C4=8Do=20dan=C3=BD=20riadok=20k=C3=B3du=20rob?= =?UTF-8?q?=C3=AD.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppsLab-010-Math/SphereCalculator.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/AppsLab-010-Math/SphereCalculator.cs b/src/AppsLab-010-Math/SphereCalculator.cs index d0874433..ed83f614 100644 --- a/src/AppsLab-010-Math/SphereCalculator.cs +++ b/src/AppsLab-010-Math/SphereCalculator.cs @@ -12,7 +12,9 @@ public class SphereCalculator /// The surface area of the sphere. public double CalculateSurface(double radius) { - throw new NotImplementedException(); + return 4 * Math.PI * Math.Pow(radius, 2); + // styri krat pi krat r na druhu + } /// @@ -22,6 +24,8 @@ public double CalculateSurface(double radius) /// The volume of the sphere. public double CalculateVolume(double radius) { - throw new NotImplementedException(); + return (4.0 / 3.0) * Math.PI * Math.Pow(radius, 3); + // styri trtiny krat pi krat r na tretiu + } } From 3bc7a35f431a4ba21bb1d8ad0c98f05e71d9a3cf Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Sun, 28 Sep 2025 13:58:56 +0200 Subject: [PATCH 16/20] opravene pouzil som metody ako to upper to lower atd --- src/AppsLab-011-Strings/StringManipulator.cs | 10 +++++----- src/AppsLab-012-Boolean/BooleanLogic.cs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/AppsLab-011-Strings/StringManipulator.cs b/src/AppsLab-011-Strings/StringManipulator.cs index f226d70d..779bf3be 100644 --- a/src/AppsLab-011-Strings/StringManipulator.cs +++ b/src/AppsLab-011-Strings/StringManipulator.cs @@ -13,7 +13,7 @@ public class StringManipulator /// The concatenated string. public string AppendStrings(string first, string second) { - throw new NotImplementedException(); + return first + second; } /// @@ -23,7 +23,7 @@ public string AppendStrings(string first, string second) /// The uppercase string. public string ConvertToUpper(string input) { - throw new NotImplementedException(); + return input.ToUpper(); } /// @@ -33,7 +33,7 @@ public string ConvertToUpper(string input) /// The lowercase string. public string ConvertToLower(string input) { - throw new NotImplementedException(); + return input.ToLower(); } /// @@ -44,7 +44,7 @@ public string ConvertToLower(string input) /// True if the substring is found, false otherwise. public bool ContainsSubstring(string input, string substring) { - throw new NotImplementedException(); + return input.Contains(substring); } /// @@ -55,6 +55,6 @@ public bool ContainsSubstring(string input, string substring) /// True if the string starts with the substring, false otherwise. public bool StartsWithSubstring(string input, string substring) { - throw new NotImplementedException(); + return input.StartsWith(substring); } } \ No newline at end of file diff --git a/src/AppsLab-012-Boolean/BooleanLogic.cs b/src/AppsLab-012-Boolean/BooleanLogic.cs index b71c40ad..06a17951 100644 --- a/src/AppsLab-012-Boolean/BooleanLogic.cs +++ b/src/AppsLab-012-Boolean/BooleanLogic.cs @@ -13,7 +13,7 @@ public class BooleanLogic /// The result of the logical AND operation. public bool And(bool a, bool b) { - throw new NotImplementedException(); + return (a && b); } /// @@ -24,7 +24,7 @@ public bool And(bool a, bool b) /// The result of the logical OR operation. public bool Or(bool a, bool b) { - throw new NotImplementedException(); + return (a || b); } /// @@ -34,6 +34,6 @@ public bool Or(bool a, bool b) /// The result of the logical NOT operation. public bool Not(bool a) { - throw new NotImplementedException(); + return (!a); } } \ No newline at end of file From 2128b86949f8392a36690867835699f037ace56b Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Sun, 28 Sep 2025 14:02:50 +0200 Subject: [PATCH 17/20] fixed --- src/AppsLab-013-Conditions/GameRules.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AppsLab-013-Conditions/GameRules.cs b/src/AppsLab-013-Conditions/GameRules.cs index 4a0ead73..419553fd 100644 --- a/src/AppsLab-013-Conditions/GameRules.cs +++ b/src/AppsLab-013-Conditions/GameRules.cs @@ -13,7 +13,7 @@ public class GameRules /// True if the player can enter the game, false otherwise. public bool CanPlayerEnterGame(string playerName, int playerAge) { - throw new NotImplementedException(); + return (!string.IsNullOrEmpty(playerName) && playerAge >= 18); } /// @@ -23,7 +23,7 @@ public bool CanPlayerEnterGame(string playerName, int playerAge) /// True if the game is over, false otherwise. public bool IsGameOver(int playerHealth) { - throw new NotImplementedException(); + return (playerHealth <= 0); } /// @@ -34,6 +34,6 @@ public bool IsGameOver(int playerHealth) /// True if the secret door should be opened, false otherwise. public bool ShouldOpenSecretDoor(bool hasKey, bool knowsPassword) { - throw new NotImplementedException(); + return (hasKey && knowsPassword); } } \ No newline at end of file From d210a03c3429c15db181765f38270126c825cdd3 Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Wed, 1 Oct 2025 17:22:53 +0200 Subject: [PATCH 18/20] urobil som funkcnu kalkulacku --- AppsLab.CSharp.Exercises.sln | 32 +++++++++++++++++++ ROJEKT2/Program.cs | 31 +++++++++++++++++++ ROJEKT2/kalkulacka.csproj | 10 ++++++ projekt1/Program.cs | 16 ++++++++++ projekt1/projekt1.csproj | 10 ++++++ src/AppsLab-008-ConsoleReadLine/Program.cs | 36 ++++++++++++---------- src/AppsLab-009-Operators/Calculator.cs | 2 +- src/AppsLab-009-Operators/Program.cs | 23 ++++++++++++++ src/AppsLab-014-Switch/MovieRating.cs | 10 +++++- 9 files changed, 151 insertions(+), 19 deletions(-) create mode 100644 ROJEKT2/Program.cs create mode 100644 ROJEKT2/kalkulacka.csproj create mode 100644 projekt1/Program.cs create mode 100644 projekt1/projekt1.csproj create mode 100644 src/AppsLab-009-Operators/Program.cs diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index e4886004..82d5aa19 100644 --- a/AppsLab.CSharp.Exercises.sln +++ b/AppsLab.CSharp.Exercises.sln @@ -95,6 +95,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppsLab-034-Debug", "src\Ap EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "test\test.csproj", "{5524A60A-E442-43DC-B5D3-F12129B2B1DB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "projekt1", "projekt1\projekt1.csproj", "{A02049C9-C1E0-4BFF-BAE0-1C83A0D16BCC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "kalkulacka", "ROJEKT2\kalkulacka.csproj", "{C8E34CC7-534B-4183-8794-CEE3803436BE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -633,6 +637,30 @@ Global {5524A60A-E442-43DC-B5D3-F12129B2B1DB}.Release|x64.Build.0 = Release|Any CPU {5524A60A-E442-43DC-B5D3-F12129B2B1DB}.Release|x86.ActiveCfg = Release|Any CPU {5524A60A-E442-43DC-B5D3-F12129B2B1DB}.Release|x86.Build.0 = Release|Any CPU + {A02049C9-C1E0-4BFF-BAE0-1C83A0D16BCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A02049C9-C1E0-4BFF-BAE0-1C83A0D16BCC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A02049C9-C1E0-4BFF-BAE0-1C83A0D16BCC}.Debug|x64.ActiveCfg = Debug|Any CPU + {A02049C9-C1E0-4BFF-BAE0-1C83A0D16BCC}.Debug|x64.Build.0 = Debug|Any CPU + {A02049C9-C1E0-4BFF-BAE0-1C83A0D16BCC}.Debug|x86.ActiveCfg = Debug|Any CPU + {A02049C9-C1E0-4BFF-BAE0-1C83A0D16BCC}.Debug|x86.Build.0 = Debug|Any CPU + {A02049C9-C1E0-4BFF-BAE0-1C83A0D16BCC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A02049C9-C1E0-4BFF-BAE0-1C83A0D16BCC}.Release|Any CPU.Build.0 = Release|Any CPU + {A02049C9-C1E0-4BFF-BAE0-1C83A0D16BCC}.Release|x64.ActiveCfg = Release|Any CPU + {A02049C9-C1E0-4BFF-BAE0-1C83A0D16BCC}.Release|x64.Build.0 = Release|Any CPU + {A02049C9-C1E0-4BFF-BAE0-1C83A0D16BCC}.Release|x86.ActiveCfg = Release|Any CPU + {A02049C9-C1E0-4BFF-BAE0-1C83A0D16BCC}.Release|x86.Build.0 = Release|Any CPU + {C8E34CC7-534B-4183-8794-CEE3803436BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C8E34CC7-534B-4183-8794-CEE3803436BE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C8E34CC7-534B-4183-8794-CEE3803436BE}.Debug|x64.ActiveCfg = Debug|Any CPU + {C8E34CC7-534B-4183-8794-CEE3803436BE}.Debug|x64.Build.0 = Debug|Any CPU + {C8E34CC7-534B-4183-8794-CEE3803436BE}.Debug|x86.ActiveCfg = Debug|Any CPU + {C8E34CC7-534B-4183-8794-CEE3803436BE}.Debug|x86.Build.0 = Debug|Any CPU + {C8E34CC7-534B-4183-8794-CEE3803436BE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C8E34CC7-534B-4183-8794-CEE3803436BE}.Release|Any CPU.Build.0 = Release|Any CPU + {C8E34CC7-534B-4183-8794-CEE3803436BE}.Release|x64.ActiveCfg = Release|Any CPU + {C8E34CC7-534B-4183-8794-CEE3803436BE}.Release|x64.Build.0 = Release|Any CPU + {C8E34CC7-534B-4183-8794-CEE3803436BE}.Release|x86.ActiveCfg = Release|Any CPU + {C8E34CC7-534B-4183-8794-CEE3803436BE}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -682,5 +710,9 @@ Global {38FFE1DF-4B49-40C1-9908-51860BCF2D3E} = {56555FB0-B513-49EF-9002-A5AF135EA090} {83C963FD-DC23-46E8-9545-F56197164810} = {56555FB0-B513-49EF-9002-A5AF135EA090} {5524A60A-E442-43DC-B5D3-F12129B2B1DB} = {56555FB0-B513-49EF-9002-A5AF135EA090} + {C8E34CC7-534B-4183-8794-CEE3803436BE} = {56555FB0-B513-49EF-9002-A5AF135EA090} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {87DB432D-BF83-4F67-A077-8E0F02BE9F55} EndGlobalSection EndGlobal diff --git a/ROJEKT2/Program.cs b/ROJEKT2/Program.cs new file mode 100644 index 00000000..78cb7809 --- /dev/null +++ b/ROJEKT2/Program.cs @@ -0,0 +1,31 @@ +Console.WriteLine("Zadaj prve cislo: "); +int cislo1 = int.Parse(Console.ReadLine()); +Console.WriteLine("Zadaj druhe cislo:"); +int cislo2 = int.Parse(Console.ReadLine()); +Console.WriteLine("Zadaj operaciu (+, -, *, /, %):"); +string operacia = Console.ReadLine(); + +int vysedlok = operacia switch +{ + "+" => (cislo1 + cislo2), + "*" => (cislo1 * cislo2), + "/" => (cislo1 / cislo2), + "%" => (cislo1 % cislo2), +}; +Console.WriteLine($"Vysledok je: {vysedlok}"); +Console.WriteLine("Stlac ENTER pre spustenie kalkulacky"); +Console.ReadLine(); +System.Diagnostics.Process.Start("kalkulacka.exe"); +System.Environment.Exit(0); + + + + +// nacitam prve cslo +//nacitam operaciu +//nacitam druhe cislo +//vypisem vypisem operaciu +//vypisem vysledok + + + diff --git a/ROJEKT2/kalkulacka.csproj b/ROJEKT2/kalkulacka.csproj new file mode 100644 index 00000000..fd4bd08d --- /dev/null +++ b/ROJEKT2/kalkulacka.csproj @@ -0,0 +1,10 @@ + + + + Exe + net9.0 + enable + enable + + + diff --git a/projekt1/Program.cs b/projekt1/Program.cs new file mode 100644 index 00000000..d75b4508 --- /dev/null +++ b/projekt1/Program.cs @@ -0,0 +1,16 @@ +int a = 10; +int b = 5; +int plus = a + b; +int minus = a - b; +int krat = a * b; +int deleno = a / b; +int zostatok = a % b; +bool rovnake = a == b; +bool rozne = a != b; +bool vacsie = a > b; +bool mensie = a < b; +bool vacsieRovnake = a >= b; +bool mensieRovnake = a <= b; + Console.WriteLine($"{plus} {minus} {krat} {deleno} {zostatok} {rovnake} {rozne} {vacsie} { mensie} {vacsieRovnake} {mensieRovnake}"); + + diff --git a/projekt1/projekt1.csproj b/projekt1/projekt1.csproj new file mode 100644 index 00000000..fd4bd08d --- /dev/null +++ b/projekt1/projekt1.csproj @@ -0,0 +1,10 @@ + + + + Exe + net9.0 + enable + enable + + + diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 1979f0d1..221c56e6 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -1,20 +1,22 @@ - -Console.WriteLine("ako sa volas?"); -string ? meno = Console.ReadLine(); -Console.WriteLine($"Ahoj {meno} Kolko mas rokov?"); -int vek = int.Parse(Console.ReadLine()); -Console.WriteLine($"AHA mas teda {vek} rokov"); -Console.WriteLine("ake je tvoje oblubene jedlo ?"); -string jedlo = Console.ReadLine(); -Console.WriteLine($" hmm {jedlo} znie skvele"); -Console.WriteLine("stlac klavesu :"); -var key = Console.ReadKey(); -Console.WriteLine(); -Console.WriteLine($"stlacili ste klavesu: {key.KeyChar}"); - - - - +// privitanie +Console.WriteLine("Vitaj v kalkulacke!"); +// zadame cislo a operciu +Console.WriteLine("Zadaj prve cislo:"); +int cislo = int.Parse(Console.ReadLine()!); +Console.WriteLine("Zadaj druhe cislo:"); +int cislo2 = int.Parse(Console.ReadLine()!); +Console.WriteLine("Zadaj operaciu (+, -, *, /, ):"); +string operacia = Console.ReadLine()!; +int vysledok = operacia switch +// zvolim operaciu a spocittamm +{ + "+" => cislo + cislo2, + "-" => cislo - cislo2, + "*" => cislo * cislo2, + "/" => cislo / cislo2, +}; +// vypisem vysledok +Console.WriteLine($"Vysledok je: {vysledok}"); diff --git a/src/AppsLab-009-Operators/Calculator.cs b/src/AppsLab-009-Operators/Calculator.cs index 5379f246..43e42bc4 100644 --- a/src/AppsLab-009-Operators/Calculator.cs +++ b/src/AppsLab-009-Operators/Calculator.cs @@ -34,7 +34,7 @@ public int Multiply(int a, int b) /// public double Divide(int a, int b) { - return (double)a / b; + return (double) a / b; } diff --git a/src/AppsLab-009-Operators/Program.cs b/src/AppsLab-009-Operators/Program.cs new file mode 100644 index 00000000..221c56e6 --- /dev/null +++ b/src/AppsLab-009-Operators/Program.cs @@ -0,0 +1,23 @@ +// privitanie +Console.WriteLine("Vitaj v kalkulacke!"); +// zadame cislo a operciu +Console.WriteLine("Zadaj prve cislo:"); +int cislo = int.Parse(Console.ReadLine()!); +Console.WriteLine("Zadaj druhe cislo:"); +int cislo2 = int.Parse(Console.ReadLine()!); +Console.WriteLine("Zadaj operaciu (+, -, *, /, ):"); +string operacia = Console.ReadLine()!; +int vysledok = operacia switch +// zvolim operaciu a spocittamm +{ + "+" => cislo + cislo2, + "-" => cislo - cislo2, + "*" => cislo * cislo2, + "/" => cislo / cislo2, +}; +// vypisem vysledok +Console.WriteLine($"Vysledok je: {vysledok}"); + + + + diff --git a/src/AppsLab-014-Switch/MovieRating.cs b/src/AppsLab-014-Switch/MovieRating.cs index ab689d49..3f0f351e 100644 --- a/src/AppsLab-014-Switch/MovieRating.cs +++ b/src/AppsLab-014-Switch/MovieRating.cs @@ -12,6 +12,14 @@ public class MovieRating /// A string describing the specified movie rating. public string GetRatingDescription(int rating) { - throw new NotImplementedException(); + return rating switch + { + 1 => "Veľmi zlý", + 2 => "Zlý", + 3 => "Priemerný", + 4 => "Dobrý", + 5 => "Výborný", + _ => "Neplatné hodnotenie", + }; } } \ No newline at end of file From 3675e231ea46a6bd93a35d09327df7a15c444338 Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Wed, 8 Oct 2025 10:56:46 +0200 Subject: [PATCH 19/20] sigma --- ROJEKT2/Program.cs | 19 ++++++++--- src/AppsLab-015-Arrays/ArrayProcessor.cs | 22 +++++++++--- src/AppsLab-016-Loops/WeatherStats.cs | 11 +++--- test/Program.cs | 43 ++++++++++++++++++++++-- 4 files changed, 79 insertions(+), 16 deletions(-) diff --git a/ROJEKT2/Program.cs b/ROJEKT2/Program.cs index 78cb7809..9b3cb9ef 100644 --- a/ROJEKT2/Program.cs +++ b/ROJEKT2/Program.cs @@ -1,13 +1,24 @@ Console.WriteLine("Zadaj prve cislo: "); -int cislo1 = int.Parse(Console.ReadLine()); +decimal cislo1 = decimal.Parse(Console.ReadLine()); Console.WriteLine("Zadaj druhe cislo:"); -int cislo2 = int.Parse(Console.ReadLine()); +decimal cislo2 = decimal.Parse(Console.ReadLine()); Console.WriteLine("Zadaj operaciu (+, -, *, /, %):"); string operacia = Console.ReadLine(); +if (operacia == "/" && cislo2 == 0) +{ + Console.WriteLine("Chyba: Delenie nulou nie je povolene."); + return; +} +if (operacia != "+" && operacia != "-" && operacia != "*" && operacia != "/" && operacia != "%") +{ + Console.WriteLine("Chyba: Neplatna operacia."); + return; +} -int vysedlok = operacia switch +decimal vysedlok = operacia switch { "+" => (cislo1 + cislo2), + "-" => (cislo1 - cislo2), "*" => (cislo1 * cislo2), "/" => (cislo1 / cislo2), "%" => (cislo1 % cislo2), @@ -27,5 +38,3 @@ //vypisem vypisem operaciu //vypisem vysledok - - diff --git a/src/AppsLab-015-Arrays/ArrayProcessor.cs b/src/AppsLab-015-Arrays/ArrayProcessor.cs index 59f8d1c7..597dd506 100644 --- a/src/AppsLab-015-Arrays/ArrayProcessor.cs +++ b/src/AppsLab-015-Arrays/ArrayProcessor.cs @@ -13,7 +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 == null || numbers.Length == 0) + { + return 0; + } + return numbers[0]; } /// @@ -23,8 +27,13 @@ public int GetFirstElement(int[] numbers) /// Array of integers. /// Last element of the array, or 0 if array is empty. public int GetLastElement(int[] numbers) + { - throw new NotImplementedException(); + if (numbers == null|| numbers.Length == 0) + { + return 0; + } + return numbers[numbers.Length - 1]; } /// @@ -36,7 +45,12 @@ 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 (position < 0 || position >= numbers.Length || + numbers == null || numbers.Length == 0) + { + return 0; + } + return numbers[position]; } /// @@ -46,6 +60,6 @@ public int GetElementAtPosition(int[] numbers, int position) /// Length of the array. public int GetLength(int[] numbers) { - throw new NotImplementedException(); + return numbers.Length; } } diff --git a/src/AppsLab-016-Loops/WeatherStats.cs b/src/AppsLab-016-Loops/WeatherStats.cs index 8bca9659..6d700571 100644 --- a/src/AppsLab-016-Loops/WeatherStats.cs +++ b/src/AppsLab-016-Loops/WeatherStats.cs @@ -1,4 +1,6 @@ -namespace AppsLab_016_Loops; +using System.Security.Cryptography; + +namespace AppsLab_016_Loops; /// /// Class to calculate weather statistics. @@ -12,17 +14,16 @@ public class WeatherStats /// Average temperature. public double AverageTemperature(double[] temperatures) { - throw new NotImplementedException(); - } + return temperatures.Length == 0 ? 0 : temperatures.Sum() / temperatures.Length; /// /// Find the maximum temperature from the provided values. /// - /// Array of temperatures. + /// Array of temperatures.x /// Maximum temperature. public double MaxTemperature(double[] temperatures) { - throw new NotImplementedException(); + throw new NotImplementedException(); } /// diff --git a/test/Program.cs b/test/Program.cs index e19ea654..722ec8d8 100644 --- a/test/Program.cs +++ b/test/Program.cs @@ -1,5 +1,44 @@ -Console.WriteLine("zadaj svoje meno"); +/*Console.WriteLine("zadaj svoje meno"); string name = Console.ReadLine(); Console.WriteLine("zadaj svoj vek"); int age = int.Parse(Console.ReadLine()); -Console.WriteLine($"ahoj tvoje meno je {name} a mas {age} rokov"); \ No newline at end of file +Console.WriteLine($"ahoj tvoje meno je {name} a mas {age} rokov"); +*/ +Console.WriteLine("zadaj cislo od 1 do 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; +} +if (dayOfweek <1 || dayOfweek > 7) +{ + Console.WriteLine("Zadal si nespravne cislo"); +} + + + + + + + + From 2686419875387632fb0ff2f9769f94472918b2cb Mon Sep 17 00:00:00 2001 From: Alex Ozaniak Date: Wed, 8 Oct 2025 19:18:21 +0200 Subject: [PATCH 20/20] =?UTF-8?q?Pridan=C3=A9=20kontroly=20na=20null=20a?= =?UTF-8?q?=20pr=C3=A1zdne=20polia=20do=20met=C3=B3d=20v=20triede=20ArrayP?= =?UTF-8?q?rocessor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upravil som všetky metódy v triede ArrayProcessor tak, aby bezpečne spracovali situácie, keď je vstupné pole null alebo prázdne. - Pridal som podmienky na kontrolu null a dĺžky poľa v metódach GetFirstElement, GetLastElement a GetElementAtPosition - Metódy teraz vracajú hodnotu 0 namiesto vyvolania výnimky (NullReferenceException alebo IndexOutOfRangeException) - Týmto sa zlepšila stabilita a spoľahlivosť triedy - Pridal som aj komentáre, ktoré vysvetľujú nové kontroly pre lepšiu čitateľnosť kódu (AI (nechelo sa mi vymylsat co tu mam pisat )) --- src/AppsLab-015-Arrays/ArrayProcessor.cs | 6 ++- src/AppsLab-016-Loops/WeatherStats.cs | 5 ++- test/Program.cs | 56 ++++++------------------ 3 files changed, 22 insertions(+), 45 deletions(-) diff --git a/src/AppsLab-015-Arrays/ArrayProcessor.cs b/src/AppsLab-015-Arrays/ArrayProcessor.cs index 597dd506..988f1ccd 100644 --- a/src/AppsLab-015-Arrays/ArrayProcessor.cs +++ b/src/AppsLab-015-Arrays/ArrayProcessor.cs @@ -13,11 +13,15 @@ public class ArrayProcessor /// First element of the array, or 0 if array is empty. public int GetFirstElement(int[] numbers) { - if (numbers == null || numbers.Length == 0) + if (numbers == null || numbers.Length == 0) + //ak je pole null alebo prazdne + { return 0; + // vrat 0 } return numbers[0]; + // vrat prvy prvok pola } /// diff --git a/src/AppsLab-016-Loops/WeatherStats.cs b/src/AppsLab-016-Loops/WeatherStats.cs index 6d700571..87775d7d 100644 --- a/src/AppsLab-016-Loops/WeatherStats.cs +++ b/src/AppsLab-016-Loops/WeatherStats.cs @@ -14,7 +14,8 @@ public class WeatherStats /// Average temperature. public double AverageTemperature(double[] temperatures) { - return temperatures.Length == 0 ? 0 : temperatures.Sum() / temperatures.Length; + return temperatures.Length == 0 ? 0 : temperatures.Sum() / temperatures.Length; + } /// /// Find the maximum temperature from the provided values. @@ -23,7 +24,7 @@ public double AverageTemperature(double[] temperatures) /// Maximum temperature. public double MaxTemperature(double[] temperatures) { - throw new NotImplementedException(); + return } /// diff --git a/test/Program.cs b/test/Program.cs index 722ec8d8..f2b127a7 100644 --- a/test/Program.cs +++ b/test/Program.cs @@ -1,44 +1,16 @@ -/*Console.WriteLine("zadaj svoje meno"); -string name = Console.ReadLine(); -Console.WriteLine("zadaj svoj vek"); -int age = int.Parse(Console.ReadLine()); -Console.WriteLine($"ahoj tvoje meno je {name} a mas {age} rokov"); -*/ -Console.WriteLine("zadaj cislo od 1 do 7"); -int dayOfweek = int.Parse(Console.ReadLine()); -switch (dayOfweek) + +string[] names = new string[] {"Jozef", "Marek", "Anna", "Eva", "Peter"}; +string[,] matrix = new string[30,5]; +matrix [0,2] = "Jozef"; +matrix [1,2] = "Marek"; +matrix [2,2] = "Anna"; +matrix [25,2] = "Eva"; +for (int i = 0; i < 30; i++) { - 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; + for (int j = 0; j < 5; j++) + { + + Console.Write(matrix[i, j ] + " ,"); + } + Console.WriteLine(); } -if (dayOfweek <1 || dayOfweek > 7) -{ - Console.WriteLine("Zadal si nespravne cislo"); -} - - - - - - - -