From 29ce43822f209adfc8341b7edd84a1dd1db0079e Mon Sep 17 00:00:00 2001 From: patrik Date: Wed, 10 Sep 2025 10:43:26 +0200 Subject: [PATCH 01/11] opravil som --- 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..180f4a71 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 6f3e251eb2b94089f14d5c142f5b74aaafa38daf Mon Sep 17 00:00:00 2001 From: patrik Date: Wed, 10 Sep 2025 11:40:16 +0200 Subject: [PATCH 02/11] urobil som vetu --- 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..b6623f7d 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 = "Patrik" ; + +Console.WriteLine($"My name is {name}, you i am {age} years old!"); + + From 1acc30e34d4cd0cd5108c2ce35c89a4bda5cd662 Mon Sep 17 00:00:00 2001 From: patrik Date: Wed, 24 Sep 2025 09:26:39 +0200 Subject: [PATCH 03/11] vypisal som datum,vypisal som slovo,vypisal som sucet a splnil ulohy 5 a 6 --- src/AppsLab-005-DataTypes/Program.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/AppsLab-005-DataTypes/Program.cs b/src/AppsLab-005-DataTypes/Program.cs index 3751555c..e9c4d35d 100644 --- a/src/AppsLab-005-DataTypes/Program.cs +++ b/src/AppsLab-005-DataTypes/Program.cs @@ -1,2 +1,20 @@ // See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +int mojeCislo = 10; +string mojeSlovo = "Ahoj Svet"; +bool mojaBoolhoHodnota = true; +DateTime dnesnydatum = DateTime.Now; +float myfloat = 20.54f; +var myvar = ("var string ide"); + +int sucet = mojeCislo + 5; + +Console.WriteLine($"Súčet je: {sucet}"); +Console.WriteLine($"Dnes je: {dnesnydatum.ToString("yyyy-MM-dd")}"); +Console.WriteLine($"Moje slovo je: {mojeSlovo}"); +Console.WriteLine($"Moja bool hodnota je: {mojaBoolhoHodnota}"); +Console.WriteLine("10"); +Console.WriteLine(myfloat); +Console.WriteLine(myvar); + + + From 2a7fd3053311b19a63e4e6f676169099e140ef58 Mon Sep 17 00:00:00 2001 From: patrik Date: Wed, 24 Sep 2025 12:27:07 +0200 Subject: [PATCH 04/11] opravil som test --- src/AppsLab-006-Constants/Program.cs | 10 +++++++++- src/AppsLab-007-Casting/Converter.cs | 15 ++++++++------- tests/AppsLab-007-Casting.Tests/ConverterTests.cs | 6 +++--- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/AppsLab-006-Constants/Program.cs b/src/AppsLab-006-Constants/Program.cs index 3751555c..1bcbbe10 100644 --- a/src/AppsLab-006-Constants/Program.cs +++ b/src/AppsLab-006-Constants/Program.cs @@ -1,2 +1,10 @@ // 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 = ("Vitajte v nasej hre"); + +Console.WriteLine(MaxPoints); +Console.WriteLine(MinAgeForDriversLicense); +Console.WriteLine(WelcomeMessage); + + diff --git a/src/AppsLab-007-Casting/Converter.cs b/src/AppsLab-007-Casting/Converter.cs index a64ce567..3ad4b146 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,7 @@ public double IntToDouble(int number) /// public int DoubleToInt(double number) { - throw new NotImplementedException(); + return Convert.ToInt32(number); } /// @@ -26,7 +27,7 @@ public int DoubleToInt(double number) /// public double StringToDouble(string number) { - throw new NotImplementedException(); + return Convert.ToDouble(number); } /// @@ -34,7 +35,7 @@ public double StringToDouble(string number) /// public string DoubleToString(double number) { - throw new NotImplementedException(); + return Convert.ToString(number); } /// @@ -42,7 +43,7 @@ public string DoubleToString(double number) /// public string IntToString(int number) { - throw new NotImplementedException(); + return Convert.ToString(number); } /// @@ -50,7 +51,7 @@ public string IntToString(int number) /// public bool StringToBool(string boolValue) { - throw new NotImplementedException(); + return Convert.ToBoolean(boolValue); } /// @@ -58,6 +59,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..7c95b1bf 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); + var result = converter.DoubleToInt(7.2); Assert.That(result, Is.EqualTo(7), "DoubleToInt(7.8) 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 60000cc317a995f746bc94e85cd929e1f40ddea9 Mon Sep 17 00:00:00 2001 From: patrik Date: Wed, 24 Sep 2025 13:02:04 +0200 Subject: [PATCH 05/11] doplnil som otazku --- src/AppsLab-008-ConsoleReadLine/Program.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 6f7376c9..f92317c7 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -5,4 +5,10 @@ Console.WriteLine("Koľko máš rokov?"); string vstup = Console.ReadLine() ?? "0"; int vek = int.Parse(vstup); -Console.WriteLine("Máš " + vek + " rokov."); +Console.WriteLine("Aha mas teda " + vek + " rokov."); + +Console.WriteLine("Ake je tvoje oblubene jedlo"); + string food = Console.ReadLine(); +Console.WriteLine("Tvoje oblubene jedlo je " + food); + + From 973bc588e159c7653e5afed82d3aaf462283db6b Mon Sep 17 00:00:00 2001 From: patrik Date: Tue, 30 Sep 2025 16:23:57 +0200 Subject: [PATCH 06/11] urobil som bonusovu ulohu a pridal som este dalsie otazky --- src/AppsLab-008-ConsoleReadLine/Program.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index f92317c7..2917a075 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -11,4 +11,12 @@ string food = Console.ReadLine(); Console.WriteLine("Tvoje oblubene jedlo je " + food); +Console.WriteLine("Aká je tvoja výška v metroch?"); +string vyskaText = Console.ReadLine() ?? "0"; +Console.WriteLine("Ok tvoja výška je " + vyskaText + " metrov."); + +Console.WriteLgine("Stlac klavesu ENTER pre ukoncenie"); +var key = Console.ReadKey (); +Console.WriteLine("Stlacena klavesa je " + key.KeyChar); + From 54d5dedfc178648fe5aaa690735725b0a6ac4063 Mon Sep 17 00:00:00 2001 From: patrik Date: Wed, 1 Oct 2025 18:09:06 +0200 Subject: [PATCH 07/11] opravil som chyby --- AppsLab.CSharp.Exercises.sln | 63 ++++++++++++++++------ Kalkulacka/Kalkulacka.csproj | 10 ++++ Kalkulacka/Program.cs | 62 +++++++++++++++++++++ projekt1/Program.cs | 28 ++++++++++ projekt1/projekt1.csproj | 10 ++++ projekt2/Program.cs | 16 ++++++ projekt2/projekt2.csproj | 10 ++++ src/AppsLab-008-ConsoleReadLine/Program.cs | 37 ++++++------- src/AppsLab-009-Operators/Calculator.cs | 23 ++++---- 9 files changed, 212 insertions(+), 47 deletions(-) create mode 100644 Kalkulacka/Kalkulacka.csproj create mode 100644 Kalkulacka/Program.cs create mode 100644 projekt1/Program.cs create mode 100644 projekt1/projekt1.csproj create mode 100644 projekt2/Program.cs create mode 100644 projekt2/projekt2.csproj diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index 58bbf6b5..1bd3130a 100644 --- a/AppsLab.CSharp.Exercises.sln +++ b/AppsLab.CSharp.Exercises.sln @@ -93,10 +93,13 @@ 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}") = "projekt1", "projekt1\projekt1.csproj", "{5D133EF7-104A-4218-ACC7-17E45C2E9585}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "projekt2", "projekt2\projekt2.csproj", "{CE44069A-983B-468A-B7B0-CA9B76C7540C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kalkulacka", "Kalkulacka\Kalkulacka.csproj", "{9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}" +EndProject Global - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 @@ -226,18 +229,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 +625,45 @@ 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 + {5D133EF7-104A-4218-ACC7-17E45C2E9585}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D133EF7-104A-4218-ACC7-17E45C2E9585}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D133EF7-104A-4218-ACC7-17E45C2E9585}.Debug|x64.ActiveCfg = Debug|Any CPU + {5D133EF7-104A-4218-ACC7-17E45C2E9585}.Debug|x64.Build.0 = Debug|Any CPU + {5D133EF7-104A-4218-ACC7-17E45C2E9585}.Debug|x86.ActiveCfg = Debug|Any CPU + {5D133EF7-104A-4218-ACC7-17E45C2E9585}.Debug|x86.Build.0 = Debug|Any CPU + {5D133EF7-104A-4218-ACC7-17E45C2E9585}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D133EF7-104A-4218-ACC7-17E45C2E9585}.Release|Any CPU.Build.0 = Release|Any CPU + {5D133EF7-104A-4218-ACC7-17E45C2E9585}.Release|x64.ActiveCfg = Release|Any CPU + {5D133EF7-104A-4218-ACC7-17E45C2E9585}.Release|x64.Build.0 = Release|Any CPU + {5D133EF7-104A-4218-ACC7-17E45C2E9585}.Release|x86.ActiveCfg = Release|Any CPU + {5D133EF7-104A-4218-ACC7-17E45C2E9585}.Release|x86.Build.0 = Release|Any CPU + {CE44069A-983B-468A-B7B0-CA9B76C7540C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE44069A-983B-468A-B7B0-CA9B76C7540C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CE44069A-983B-468A-B7B0-CA9B76C7540C}.Debug|x64.ActiveCfg = Debug|Any CPU + {CE44069A-983B-468A-B7B0-CA9B76C7540C}.Debug|x64.Build.0 = Debug|Any CPU + {CE44069A-983B-468A-B7B0-CA9B76C7540C}.Debug|x86.ActiveCfg = Debug|Any CPU + {CE44069A-983B-468A-B7B0-CA9B76C7540C}.Debug|x86.Build.0 = Debug|Any CPU + {CE44069A-983B-468A-B7B0-CA9B76C7540C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CE44069A-983B-468A-B7B0-CA9B76C7540C}.Release|Any CPU.Build.0 = Release|Any CPU + {CE44069A-983B-468A-B7B0-CA9B76C7540C}.Release|x64.ActiveCfg = Release|Any CPU + {CE44069A-983B-468A-B7B0-CA9B76C7540C}.Release|x64.Build.0 = Release|Any CPU + {CE44069A-983B-468A-B7B0-CA9B76C7540C}.Release|x86.ActiveCfg = Release|Any CPU + {CE44069A-983B-468A-B7B0-CA9B76C7540C}.Release|x86.Build.0 = Release|Any CPU + {9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}.Debug|x64.ActiveCfg = Debug|Any CPU + {9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}.Debug|x64.Build.0 = Debug|Any CPU + {9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}.Debug|x86.ActiveCfg = Debug|Any CPU + {9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}.Debug|x86.Build.0 = Debug|Any CPU + {9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}.Release|Any CPU.Build.0 = Release|Any CPU + {9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}.Release|x64.ActiveCfg = Release|Any CPU + {9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}.Release|x64.Build.0 = Release|Any CPU + {9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}.Release|x86.ActiveCfg = Release|Any CPU + {9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}.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} @@ -680,4 +710,7 @@ Global {38FFE1DF-4B49-40C1-9908-51860BCF2D3E} = {56555FB0-B513-49EF-9002-A5AF135EA090} {83C963FD-DC23-46E8-9545-F56197164810} = {56555FB0-B513-49EF-9002-A5AF135EA090} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {35C183AD-8455-4668-A0C5-0134A189807B} + EndGlobalSection EndGlobal diff --git a/Kalkulacka/Kalkulacka.csproj b/Kalkulacka/Kalkulacka.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/Kalkulacka/Kalkulacka.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Kalkulacka/Program.cs b/Kalkulacka/Program.cs new file mode 100644 index 00000000..78aa04a5 --- /dev/null +++ b/Kalkulacka/Program.cs @@ -0,0 +1,62 @@ +ConsoleColor consoleColor = ConsoleColor.DarkGray; +Console.BackgroundColor = consoleColor; +Console.Clear(); +Console.ForegroundColor = ConsoleColor.Black; +System.Console.Title = "Kalkulacka v0.1 by Patrik"; + + + + + + + +//nacitam prve cislo +//nacitam druhe cislo +//nacitam operaciu +//vypisem vysledok +Console.WriteLine("Vytaj v kalkulacke"); +Console.WriteLine("Zadaj prve cislo"); +double prveCislo = double.Parse(Console.ReadLine()); +Console.WriteLine("Zadaj druhe cislo"); +double druheCislo = double.Parse(Console.ReadLine()); +Console.WriteLine("Zadaj operaciu (+, -, *, /)"); +string operacia = Console.ReadLine(); +double vysledok = 0; + +if (operacia == "-") +{ + vysledok = prveCislo - druheCislo; +} +else if (operacia == "+") +{ + vysledok = prveCislo + druheCislo; +} +else if (operacia == "*") +{ + vysledok = prveCislo * druheCislo; +} +else if (operacia == "/") +{ + if (druheCislo != 0) + { + vysledok = prveCislo / druheCislo; + } + else + { + Console.WriteLine("SynTax EROR : nulou sa neda delit"); + return; // Ukonci program, aby sa nevypisal nespravny vysledok + } +} +else +{ + Console.WriteLine("Chyba: neplatna operacia."); + return; // Ukonci program, aby sa nevypisal nespravny vysledok +} +Console.WriteLine($"Tvoj v7sledok je : {vysledok}"); + +Console.WriteLine("Pre reset programu strac ENTER"); +Console.ReadLine(); +System.Diagnostics.Process.Start("Kalkulacka.exe"); +Environment.Exit(0); + + diff --git a/projekt1/Program.cs b/projekt1/Program.cs new file mode 100644 index 00000000..60669973 --- /dev/null +++ b/projekt1/Program.cs @@ -0,0 +1,28 @@ +Console.BackgroundColor = ConsoleColor.DarkBlue; +Console.Clear(); + + + +int a = 55; +int b = 35; +int sum = a + b; +int minus = a - b; +int multiply = a * b; +int remainder = a % b; +int divide = a / b; +bool vecsie = a > b; +bool rovnake = a == b; +bool vecsieRovnake = a >= b; +bool mensieRovnake = a <= b; +decimal division = a / (decimal)b; + +Console.WriteLine($"Suma {a} a {b} je {sum}"); +Console.WriteLine($"Rozdiel {a} a {b} je {minus}"); +Console.WriteLine($"Nasobok {a} a {b} je {multiply}"); +Console.WriteLine($"Zostatok po deleni {a} a {b} je {remainder}"); +Console.WriteLine($"Podiel {a} a {b} je {divide}"); +Console.WriteLine($"{a} je vacsie ako {b} : {vecsie}"); +Console.WriteLine($"{a} je rovnake ako {b} : {rovnake}"); +Console.WriteLine($"{a} je vacsie alebo rovnake ako {b} : {vecsieRovnake}"); +Console.WriteLine(division); + diff --git a/projekt1/projekt1.csproj b/projekt1/projekt1.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/projekt1/projekt1.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/projekt2/Program.cs b/projekt2/Program.cs new file mode 100644 index 00000000..a1b6f0aa --- /dev/null +++ b/projekt2/Program.cs @@ -0,0 +1,16 @@ + +Console.WriteLine("Zadaj cislo"); +int cislo = int.Parse(Console.ReadLine()); + +if (cislo >= 1 && cislo <= 6) +{ + Console.WriteLine("mas kocku"); +} +else if (cislo > 6) +{ + Console.WriteLine("nepoznas kocku"); +} + + + + diff --git a/projekt2/projekt2.csproj b/projekt2/projekt2.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/projekt2/projekt2.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 2917a075..98325f17 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -1,22 +1,19 @@ -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("Aha mas teda " + vek + " rokov."); - -Console.WriteLine("Ake je tvoje oblubene jedlo"); - string food = Console.ReadLine(); -Console.WriteLine("Tvoje oblubene jedlo je " + food); - -Console.WriteLine("Aká je tvoja výška v metroch?"); -string vyskaText = Console.ReadLine() ?? "0"; -Console.WriteLine("Ok tvoja výška je " + vyskaText + " metrov."); - -Console.WriteLgine("Stlac klavesu ENTER pre ukoncenie"); -var key = Console.ReadKey (); -Console.WriteLine("Stlacena klavesa je " + key.KeyChar); +Console.BackgroundColor = ConsoleColor.DarkBlue; +Console.Clear(); + + +Console.WriteLine("Vitaj v kalkulacke"); +Console.WriteLine("Zadaj prve cislo:"); +string? cislo1 = Console.ReadLine() ?? "0"; +Console.WriteLine("Zadaj druhe cislo:"); +string? cislo2 = Console.ReadLine() ?? "0"; +int sucet = int.Parse(cislo1) + int.Parse(cislo2); +Console.WriteLine($"Suma {cislo1} a {cislo2} je {sucet}"); + + + + + + diff --git a/src/AppsLab-009-Operators/Calculator.cs b/src/AppsLab-009-Operators/Calculator.cs index 981993a9..4715ca0e 100644 --- a/src/AppsLab-009-Operators/Calculator.cs +++ b/src/AppsLab-009-Operators/Calculator.cs @@ -10,15 +10,14 @@ public class Calculator /// public int Add(int a, int b) { - throw new NotImplementedException(); + return a + b; } - /// /// This method subtracts two integers and returns the difference. /// public int Subtract(int a, int b) { - throw new NotImplementedException(); + return a - b; } /// @@ -26,7 +25,7 @@ public int Subtract(int a, int b) /// public int Multiply(int a, int b) { - throw new NotImplementedException(); + return a * b; } /// @@ -34,7 +33,7 @@ public int Multiply(int a, int b) /// public double Divide(int a, int b) { - throw new NotImplementedException(); + return (double)a / b; } /// @@ -42,7 +41,7 @@ public double Divide(int a, int b) /// public int Remainder(int a, int b) { - throw new NotImplementedException(); + return a % b; } /// @@ -50,7 +49,7 @@ public int Remainder(int a, int b) /// public bool AreEqual(int a, int b) { - throw new NotImplementedException(); + return a == b; } /// @@ -58,7 +57,7 @@ public bool AreEqual(int a, int b) /// public bool AreNotEqual(int a, int b) { - throw new NotImplementedException(); + return a != b; } /// @@ -66,7 +65,7 @@ public bool AreNotEqual(int a, int b) /// public bool IsGreater(int a, int b) { - throw new NotImplementedException(); + return a > b; } /// @@ -74,7 +73,7 @@ public bool IsGreater(int a, int b) /// public bool IsLesser(int a, int b) { - throw new NotImplementedException(); + return a < b; } /// @@ -82,7 +81,7 @@ public bool IsLesser(int a, int b) /// public bool IsGreaterOrEqual(int a, int b) { - throw new NotImplementedException(); + return a >= b; } /// @@ -90,6 +89,6 @@ public bool IsGreaterOrEqual(int a, int b) /// public bool IsLesserOrEqual(int a, int b) { - throw new NotImplementedException(); + return a <= b; } } From 1a516eb3c29f243a90de787df18fa6746c8c47eb Mon Sep 17 00:00:00 2001 From: patrik Date: Wed, 1 Oct 2025 18:37:38 +0200 Subject: [PATCH 08/11] =?UTF-8?q?Urobil=20som=20funk=C4=8Dn=C3=BA=20kalkul?= =?UTF-8?q?a=C4=8Dku.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AppsLab.CSharp.Exercises.sln | 15 ++++++++ Kalkulackaa/Kalkulackaa.csproj | 10 ++++++ Kalkulackaa/Program.cs | 62 ++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 Kalkulackaa/Kalkulackaa.csproj create mode 100644 Kalkulackaa/Program.cs diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index 1bd3130a..6667381e 100644 --- a/AppsLab.CSharp.Exercises.sln +++ b/AppsLab.CSharp.Exercises.sln @@ -99,6 +99,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "projekt2", "projekt2\projek EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kalkulacka", "Kalkulacka\Kalkulacka.csproj", "{9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kalkulackaa", "Kalkulackaa\Kalkulackaa.csproj", "{ED059B73-649D-4B78-943D-A3B6A933706C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -661,6 +663,18 @@ Global {9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}.Release|x64.Build.0 = Release|Any CPU {9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}.Release|x86.ActiveCfg = Release|Any CPU {9EEF9340-3CB6-4B9D-90A4-1926493F0C4F}.Release|x86.Build.0 = Release|Any CPU + {ED059B73-649D-4B78-943D-A3B6A933706C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED059B73-649D-4B78-943D-A3B6A933706C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ED059B73-649D-4B78-943D-A3B6A933706C}.Debug|x64.ActiveCfg = Debug|Any CPU + {ED059B73-649D-4B78-943D-A3B6A933706C}.Debug|x64.Build.0 = Debug|Any CPU + {ED059B73-649D-4B78-943D-A3B6A933706C}.Debug|x86.ActiveCfg = Debug|Any CPU + {ED059B73-649D-4B78-943D-A3B6A933706C}.Debug|x86.Build.0 = Debug|Any CPU + {ED059B73-649D-4B78-943D-A3B6A933706C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED059B73-649D-4B78-943D-A3B6A933706C}.Release|Any CPU.Build.0 = Release|Any CPU + {ED059B73-649D-4B78-943D-A3B6A933706C}.Release|x64.ActiveCfg = Release|Any CPU + {ED059B73-649D-4B78-943D-A3B6A933706C}.Release|x64.Build.0 = Release|Any CPU + {ED059B73-649D-4B78-943D-A3B6A933706C}.Release|x86.ActiveCfg = Release|Any CPU + {ED059B73-649D-4B78-943D-A3B6A933706C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -709,6 +723,7 @@ 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} + {ED059B73-649D-4B78-943D-A3B6A933706C} = {56555FB0-B513-49EF-9002-A5AF135EA090} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {35C183AD-8455-4668-A0C5-0134A189807B} diff --git a/Kalkulackaa/Kalkulackaa.csproj b/Kalkulackaa/Kalkulackaa.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/Kalkulackaa/Kalkulackaa.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Kalkulackaa/Program.cs b/Kalkulackaa/Program.cs new file mode 100644 index 00000000..1cc26534 --- /dev/null +++ b/Kalkulackaa/Program.cs @@ -0,0 +1,62 @@ +ConsoleColor consoleColor = ConsoleColor.DarkGray; +Console.BackgroundColor = consoleColor; +Console.Clear(); +Console.ForegroundColor = ConsoleColor.Black; +System.Console.Title = "Kalkulacka v0.1 by Patrik"; + + + + + + + +//nacitam prve cislo +//nacitam druhe cislo +//nacitam operaciu +//vypisem vysledok +Console.WriteLine("Vytaj v kalkulacke"); +Console.WriteLine("Zadaj prve cislo"); +double prveCislo = double.Parse(Console.ReadLine()); +Console.WriteLine("Zadaj druhe cislo"); +double druheCislo = double.Parse(Console.ReadLine()); +Console.WriteLine("Zadaj operaciu (+, -, *, /)"); +string operacia = Console.ReadLine(); +double vysledok = 0; + +if (operacia == "-") +{ + vysledok = prveCislo - druheCislo; +} +else if (operacia == "+") +{ + vysledok = prveCislo + druheCislo; +} +else if (operacia == "*") +{ + vysledok = prveCislo * druheCislo; +} +else if (operacia == "/") +{ + if (druheCislo != 0) + { + vysledok = prveCislo / druheCislo; + } + else + { + Console.WriteLine("SynTax EROR : nulou sa neda delit"); + return; // Ukonci program, aby sa nevypisal nespravny vysledok + } +} +else +{ + Console.WriteLine("Chyba: neplatna operacia."); + return; // Ukonci program, aby sa nevypisal nespravny vysledok +} +Console.WriteLine($"Tvoj v7sledok je : {vysledok}"); + +Console.WriteLine("Pre reset programu strac ENTER"); +Console.ReadLine(); +System.Diagnostics.Process.Start("Kalkulackaa.exe"); +Environment.Exit(0); + + From 57f2fe932c4694b18c23783149f6169674814c31 Mon Sep 17 00:00:00 2001 From: patrik Date: Wed, 8 Oct 2025 08:45:39 +0200 Subject: [PATCH 09/11] opravil som gramaticke chyby --- Kalkulacka/Program.cs | 2 +- Kalkulackaa/Program.cs | 2 +- projekt2/Program.cs | 12 +----------- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/Kalkulacka/Program.cs b/Kalkulacka/Program.cs index 78aa04a5..3e758dd5 100644 --- a/Kalkulacka/Program.cs +++ b/Kalkulacka/Program.cs @@ -14,7 +14,7 @@ //nacitam druhe cislo //nacitam operaciu //vypisem vysledok -Console.WriteLine("Vytaj v kalkulacke"); +Console.WriteLine("Vitaj v kalkulacke"); Console.WriteLine("Zadaj prve cislo"); double prveCislo = double.Parse(Console.ReadLine()); Console.WriteLine("Zadaj druhe cislo"); diff --git a/Kalkulackaa/Program.cs b/Kalkulackaa/Program.cs index 1cc26534..22a6619b 100644 --- a/Kalkulackaa/Program.cs +++ b/Kalkulackaa/Program.cs @@ -14,7 +14,7 @@ //nacitam druhe cislo //nacitam operaciu //vypisem vysledok -Console.WriteLine("Vytaj v kalkulacke"); +Console.WriteLine("Vitaj v kalkulacke"); Console.WriteLine("Zadaj prve cislo"); double prveCislo = double.Parse(Console.ReadLine()); Console.WriteLine("Zadaj druhe cislo"); diff --git a/projekt2/Program.cs b/projekt2/Program.cs index a1b6f0aa..b2bf59bb 100644 --- a/projekt2/Program.cs +++ b/projekt2/Program.cs @@ -1,15 +1,5 @@ - -Console.WriteLine("Zadaj cislo"); -int cislo = int.Parse(Console.ReadLine()); +srting text = "quenty"; -if (cislo >= 1 && cislo <= 6) -{ - Console.WriteLine("mas kocku"); -} -else if (cislo > 6) -{ - Console.WriteLine("nepoznas kocku"); -} From e92e2fc87f52c6900aafd6278631a4243243c33f Mon Sep 17 00:00:00 2001 From: patrik Date: Tue, 14 Oct 2025 17:09:16 +0200 Subject: [PATCH 10/11] urobil som ulohu a testy mi presli --- AppsLab.CSharp.Exercises.sln | 14 +++++ Kalkulacka/Program.cs | 67 +++++------------------- monday/Program.cs | 46 ++++++++++++++++ monday/monday.csproj | 10 ++++ projekt1/Program.cs | 40 ++++++-------- src/AppsLab-014-Switch/MovieRating.cs | 33 ++++++++---- src/AppsLab-015-Arrays/ArrayProcessor.cs | 21 ++++++-- 7 files changed, 137 insertions(+), 94 deletions(-) create mode 100644 monday/Program.cs create mode 100644 monday/monday.csproj diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index 6667381e..b146077f 100644 --- a/AppsLab.CSharp.Exercises.sln +++ b/AppsLab.CSharp.Exercises.sln @@ -101,6 +101,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kalkulacka", "Kalkulacka\Ka EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kalkulackaa", "Kalkulackaa\Kalkulackaa.csproj", "{ED059B73-649D-4B78-943D-A3B6A933706C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "monday", "monday\monday.csproj", "{938BFD03-B71D-4EEE-AAAE-0F8DB54874AA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -675,6 +677,18 @@ Global {ED059B73-649D-4B78-943D-A3B6A933706C}.Release|x64.Build.0 = Release|Any CPU {ED059B73-649D-4B78-943D-A3B6A933706C}.Release|x86.ActiveCfg = Release|Any CPU {ED059B73-649D-4B78-943D-A3B6A933706C}.Release|x86.Build.0 = Release|Any CPU + {938BFD03-B71D-4EEE-AAAE-0F8DB54874AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {938BFD03-B71D-4EEE-AAAE-0F8DB54874AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {938BFD03-B71D-4EEE-AAAE-0F8DB54874AA}.Debug|x64.ActiveCfg = Debug|Any CPU + {938BFD03-B71D-4EEE-AAAE-0F8DB54874AA}.Debug|x64.Build.0 = Debug|Any CPU + {938BFD03-B71D-4EEE-AAAE-0F8DB54874AA}.Debug|x86.ActiveCfg = Debug|Any CPU + {938BFD03-B71D-4EEE-AAAE-0F8DB54874AA}.Debug|x86.Build.0 = Debug|Any CPU + {938BFD03-B71D-4EEE-AAAE-0F8DB54874AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {938BFD03-B71D-4EEE-AAAE-0F8DB54874AA}.Release|Any CPU.Build.0 = Release|Any CPU + {938BFD03-B71D-4EEE-AAAE-0F8DB54874AA}.Release|x64.ActiveCfg = Release|Any CPU + {938BFD03-B71D-4EEE-AAAE-0F8DB54874AA}.Release|x64.Build.0 = Release|Any CPU + {938BFD03-B71D-4EEE-AAAE-0F8DB54874AA}.Release|x86.ActiveCfg = Release|Any CPU + {938BFD03-B71D-4EEE-AAAE-0F8DB54874AA}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Kalkulacka/Program.cs b/Kalkulacka/Program.cs index 3e758dd5..c3389906 100644 --- a/Kalkulacka/Program.cs +++ b/Kalkulacka/Program.cs @@ -1,62 +1,19 @@ -ConsoleColor consoleColor = ConsoleColor.DarkGray; -Console.BackgroundColor = consoleColor; -Console.Clear(); -Console.ForegroundColor = ConsoleColor.Black; -System.Console.Title = "Kalkulacka v0.1 by Patrik"; +//int i = 1; +//while (i <= 1000) +//{ +// Console.WriteLine(i); +// i++; +//} +using System.ComponentModel.Design; +using System.Numerics; - - - - - -//nacitam prve cislo -//nacitam druhe cislo -//nacitam operaciu -//vypisem vysledok -Console.WriteLine("Vitaj v kalkulacke"); -Console.WriteLine("Zadaj prve cislo"); -double prveCislo = double.Parse(Console.ReadLine()); -Console.WriteLine("Zadaj druhe cislo"); -double druheCislo = double.Parse(Console.ReadLine()); -Console.WriteLine("Zadaj operaciu (+, -, *, /)"); -string operacia = Console.ReadLine(); -double vysledok = 0; - -if (operacia == "-") -{ - vysledok = prveCislo - druheCislo; -} -else if (operacia == "+") -{ - vysledok = prveCislo + druheCislo; -} -else if (operacia == "*") -{ - vysledok = prveCislo * druheCislo; -} -else if (operacia == "/") +for (int i = 1; i <= 1000; i++) { - if (druheCislo != 0) - { - vysledok = prveCislo / druheCislo; - } - else + int modulo = i % 2; + if (modulo == 0) { - Console.WriteLine("SynTax EROR : nulou sa neda delit"); - return; // Ukonci program, aby sa nevypisal nespravny vysledok + Console.WriteLine(i); } } -else -{ - Console.WriteLine("Chyba: neplatna operacia."); - return; // Ukonci program, aby sa nevypisal nespravny vysledok -} -Console.WriteLine($"Tvoj v7sledok je : {vysledok}"); - -Console.WriteLine("Pre reset programu strac ENTER"); -Console.ReadLine(); -System.Diagnostics.Process.Start("Kalkulacka.exe"); -Environment.Exit(0); - diff --git a/monday/Program.cs b/monday/Program.cs new file mode 100644 index 00000000..ebaf3889 --- /dev/null +++ b/monday/Program.cs @@ -0,0 +1,46 @@ +Console.WriteLine("Zadaj cislo od 1 do 7"); +int dayOfWeek = int.Parse(Console.ReadLine()); + + + + +{ + switch (dayOfWeek) + { + case 1: + Console.WriteLine("Monday"); + break; + case 2: + Console.WriteLine("Tuesday"); + break; + case 3: + Console.WriteLine("Wednesday"); + break; + case 4: + Console.WriteLine("Thursday"); + break; + case 5: + Console.WriteLine("Friday"); + break; + case 6: + Console.WriteLine("Saturday"); + break; + case 7: + Console.WriteLine("Sunday"); + break; + default: + Console.WriteLine("Error: Invalid day of the week."); + break; + + } +} + +int number = 3; +string result = number switch +{ + 1 => "One", + 2 => "Two", + 3 => "Three", + _ => "Other" +}; +Console.WriteLine(result); diff --git a/monday/monday.csproj b/monday/monday.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/monday/monday.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/projekt1/Program.cs b/projekt1/Program.cs index 60669973..7cdd8d0a 100644 --- a/projekt1/Program.cs +++ b/projekt1/Program.cs @@ -1,28 +1,20 @@ -Console.BackgroundColor = ConsoleColor.DarkBlue; -Console.Clear(); + +string [,] matrix = new string[30, 5]; +matrix[0, 2] = "Janko"; +matrix[0, 3] = "Fero"; +matrix[0, 4] = "Laco"; +matrix[0, 5] = "Palo"; +//vloz 4 rozne mena +//vypis vsetky mena +for (int i = 0; i < 30; i++) +{ + for (int j = 0; j < 5; j++) + { + Console.Write(matrix[i, j] + ", "); + } + Console.WriteLine(); +} -int a = 55; -int b = 35; -int sum = a + b; -int minus = a - b; -int multiply = a * b; -int remainder = a % b; -int divide = a / b; -bool vecsie = a > b; -bool rovnake = a == b; -bool vecsieRovnake = a >= b; -bool mensieRovnake = a <= b; -decimal division = a / (decimal)b; - -Console.WriteLine($"Suma {a} a {b} je {sum}"); -Console.WriteLine($"Rozdiel {a} a {b} je {minus}"); -Console.WriteLine($"Nasobok {a} a {b} je {multiply}"); -Console.WriteLine($"Zostatok po deleni {a} a {b} je {remainder}"); -Console.WriteLine($"Podiel {a} a {b} je {divide}"); -Console.WriteLine($"{a} je vacsie ako {b} : {vecsie}"); -Console.WriteLine($"{a} je rovnake ako {b} : {rovnake}"); -Console.WriteLine($"{a} je vacsie alebo rovnake ako {b} : {vecsieRovnake}"); -Console.WriteLine(division); diff --git a/src/AppsLab-014-Switch/MovieRating.cs b/src/AppsLab-014-Switch/MovieRating.cs index ab689d49..07735a12 100644 --- a/src/AppsLab-014-Switch/MovieRating.cs +++ b/src/AppsLab-014-Switch/MovieRating.cs @@ -1,17 +1,28 @@ namespace AppsLab_014_Switch; - -/// -/// Provides methods for working with movie ratings. -/// public class MovieRating { - /// - /// Gets a description of the specified movie rating. - /// - /// The movie rating to get a description for. - /// 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..62beb972 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]; } /// @@ -24,7 +28,11 @@ 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 == null || numbers.Length == 0) + { + return 0; + } + return numbers[numbers.Length - 1]; } /// @@ -36,7 +44,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 +59,6 @@ public int GetElementAtPosition(int[] numbers, int position) /// Length of the array. public int GetLength(int[] numbers) { - throw new NotImplementedException(); + return numbers.Length; } } From 2deb71a6df906428a31e299b2cc332375e2fa7b8 Mon Sep 17 00:00:00 2001 From: patrik Date: Wed, 15 Oct 2025 08:21:44 +0200 Subject: [PATCH 11/11] presli mi vsetky testy --- projekt2/Program.cs | 4 +--- src/AppsLab-011-Strings/StringManipulator.cs | 10 +++++----- src/AppsLab-015-Arrays/ArrayProcessor.cs | 2 ++ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/projekt2/Program.cs b/projekt2/Program.cs index b2bf59bb..72f0c19a 100644 --- a/projekt2/Program.cs +++ b/projekt2/Program.cs @@ -1,6 +1,4 @@ -srting text = "quenty"; - - +for () diff --git a/src/AppsLab-011-Strings/StringManipulator.cs b/src/AppsLab-011-Strings/StringManipulator.cs index f226d70d..14fdf789 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-015-Arrays/ArrayProcessor.cs b/src/AppsLab-015-Arrays/ArrayProcessor.cs index 62beb972..3d78c2d0 100644 --- a/src/AppsLab-015-Arrays/ArrayProcessor.cs +++ b/src/AppsLab-015-Arrays/ArrayProcessor.cs @@ -59,6 +59,8 @@ public int GetElementAtPosition(int[] numbers, int position) /// Length of the array. public int GetLength(int[] numbers) { + if (numbers == null) + return 0; return numbers.Length; } }