From b3197f7afc58184581232fe94366fa9b4eaaf129 Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 10 Sep 2025 10:54:27 +0200 Subject: [PATCH 01/21] opravil som pre buduce generacie --- 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 346f203792427204e3a5fb30ec47026cd26f2ae1 Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 10 Sep 2025 11:41:46 +0200 Subject: [PATCH 02/21] opravil som 2 --- 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..5eab619f 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 = 14; +string name = "Matej"; +Console.WriteLine(age); +Console.WriteLine(name); + +Console.WriteLine($"My name is {name} and I am {age} years old."); From 826fcabf78bd4d09cea54f6924c7a893c3b17c3e Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 24 Sep 2025 09:26:29 +0200 Subject: [PATCH 03/21] Urobil som ulohu 5 --- src/AppsLab-002-ConsoleWriteLine/Program.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/AppsLab-002-ConsoleWriteLine/Program.cs b/src/AppsLab-002-ConsoleWriteLine/Program.cs index 5eab619f..0efb248b 100644 --- a/src/AppsLab-002-ConsoleWriteLine/Program.cs +++ b/src/AppsLab-002-ConsoleWriteLine/Program.cs @@ -1,6 +1,15 @@ -int age = 14; -string name = "Matej"; -Console.WriteLine(age); -Console.WriteLine(name); +int mojeCislo = 15; +string mojeSlovo = "Ahoj, svet!"; +bool mojaBoolHodnota = true; +DateTime dnesnyDatum = DateTime.Now; +float myFloat = 5.5f; +int sucet = mojeCislo + 5; +var myVar = "Toto je var string"; +Console.WriteLine(mojeCislo.ToString("000000")); +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(myVar); -Console.WriteLine($"My name is {name} and I am {age} years old."); From 513fe37b29b8a94ec41d2d161adb3e526f64c156 Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 24 Sep 2025 10:35:13 +0200 Subject: [PATCH 04/21] Urobil som ulohu 6. --- src/AppsLab-002-ConsoleWriteLine/Program.cs | 18 +++--------------- src/AppsLab-005-DataTypes/Program.cs | 20 ++++++++++++++++++-- src/AppsLab-006-Constants/Program.cs | 8 ++++++-- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/AppsLab-002-ConsoleWriteLine/Program.cs b/src/AppsLab-002-ConsoleWriteLine/Program.cs index 0efb248b..5cb5b80d 100644 --- a/src/AppsLab-002-ConsoleWriteLine/Program.cs +++ b/src/AppsLab-002-ConsoleWriteLine/Program.cs @@ -1,15 +1,3 @@ -int mojeCislo = 15; -string mojeSlovo = "Ahoj, svet!"; -bool mojaBoolHodnota = true; -DateTime dnesnyDatum = DateTime.Now; -float myFloat = 5.5f; -int sucet = mojeCislo + 5; -var myVar = "Toto je var string"; -Console.WriteLine(mojeCislo.ToString("000000")); -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(myVar); - +int age = 15; +string name = "Matej"; +Console.WriteLine($"My name is {name} and I am {age}"); \ No newline at end of file diff --git a/src/AppsLab-005-DataTypes/Program.cs b/src/AppsLab-005-DataTypes/Program.cs index 3751555c..8675ef40 100644 --- a/src/AppsLab-005-DataTypes/Program.cs +++ b/src/AppsLab-005-DataTypes/Program.cs @@ -1,2 +1,18 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +int mojeCislo = 15; +string mojeSlovo = "Ahoj, svet!"; +bool mojaBoolHodnota = true; +DateTime dnesnyDatum = DateTime.Now; +float myFloat = 5.5f; +int sucet = mojeCislo + 5; +var myVar = "Toto je var string"; +const int MaxStudents = 15; + +Console.WriteLine(mojeCislo.ToString("000000")); +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(myVar); +Console.WriteLine("Maximálny počet študentov v triede je: " + MaxStudents); + diff --git a/src/AppsLab-006-Constants/Program.cs b/src/AppsLab-006-Constants/Program.cs index 3751555c..77f6d1a9 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 MinAgeDriversLicence = 20; +const string WelcomeMessage = "Vitajte v nasej triede"; +Console.WriteLine(MaxPoints); +Console.WriteLine(MinAgeDriversLicence); +Console.WriteLine(WelcomeMessage); From 5dc1e96e72ca3e75973600db574b07643d9b016c Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 24 Sep 2025 12:27:22 +0200 Subject: [PATCH 05/21] Urobil som ulohu 7. --- src/AppsLab-007-Casting/Converter.cs | 14 +++++++------- tests/AppsLab-007-Casting.Tests/ConverterTests.cs | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/AppsLab-007-Casting/Converter.cs b/src/AppsLab-007-Casting/Converter.cs index a64ce567..1ee9e308 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..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 89b598af6eed14deb9100456dab5c9e59fc2fc7f Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 24 Sep 2025 12:50:59 +0200 Subject: [PATCH 06/21] Urobil som ulohu 8. --- src/AppsLab-008-ConsoleReadLine/Program.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 6f7376c9..691ebb17 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?"); +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"); \ No newline at end of file From c99eece973528aa8766fad2e27eafb04c9b9064f Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 24 Sep 2025 13:06:59 +0200 Subject: [PATCH 07/21] Urobil som kamarata na rozhovor ked si sam. --- src/AppsLab-008-ConsoleReadLine/Program.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 691ebb17..e6a96493 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -3,4 +3,13 @@ Console.WriteLine($"Ahoj,{meno}! Kolko mas rokov?"); string vstup = Console.ReadLine() ?? "0"; int vek = int.Parse(vstup); -Console.WriteLine("Aha, mas teda 15 rokov"); \ No newline at end of file +Console.WriteLine("Aha, mas teda 15 rokov"); +Console.WriteLine("Ake je tvoje oblubune jedlo?"); +string jedlo = Console.ReadLine(); +Console.WriteLine($"Hmmm, {jedlo} to znie skvele!"); +Console.WriteLine("Aky mas dns den?"); +string den = Console.ReadLine(); +Console.WriteLine($"Tak to mas skvele!"); +Console.WriteLine("Kolko za to dostanem za snahu?"); +string text = Console.ReadLine(); +Console.WriteLine("To je zle! Skus nieco ine!"); From b72633d4955c66e2efc3c2be94b305a31c154315 Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 24 Sep 2025 13:48:28 +0200 Subject: [PATCH 08/21] Doplnenie konzoly. Uloha 8 --- src/AppsLab-008-ConsoleReadLine/Program.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index e6a96493..759d9d0a 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -10,6 +10,11 @@ Console.WriteLine("Aky mas dns den?"); string den = Console.ReadLine(); Console.WriteLine($"Tak to mas skvele!"); -Console.WriteLine("Kolko za to dostanem za snahu?"); +Console.WriteLine("Preco sa rozpravas s robotom?"); string text = Console.ReadLine(); -Console.WriteLine("To je zle! Skus nieco ine!"); +Console.WriteLine("Nemyslis ze si na tom dost zle ked sa musis rozpavat so mnou?"); +string text1 = Console.ReadLine(); +Console.WriteLine($"Tak, to by bolo zatial vsetko. Pokracovanie nabuduce."); +Console.WriteLine("Kolko dostanem cash za tento projekt?"); +string text2= Console.ReadLine(); +Console.WriteLine("Tak neni to moc ale na zaciatok staci!"); \ No newline at end of file From 6825ec41b4d9b505ce9ecaf599ad8e20d59c9caf Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 24 Sep 2025 15:12:39 +0200 Subject: [PATCH 09/21] 2. pokracovanie s konzolou. --- 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 759d9d0a..05fc3d29 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -14,6 +14,9 @@ string text = Console.ReadLine(); Console.WriteLine("Nemyslis ze si na tom dost zle ked sa musis rozpavat so mnou?"); string text1 = Console.ReadLine(); +Console.WriteLine("Aka je tvoja oblubena farba?"); +string farba = Console.ReadLine(); +Console.WriteLine($"Hmm, {farba}? Ja poznam aj krajsie ale tak je to tvoja vec. Kazdemu sa paci nieco ine."); Console.WriteLine($"Tak, to by bolo zatial vsetko. Pokracovanie nabuduce."); Console.WriteLine("Kolko dostanem cash za tento projekt?"); string text2= Console.ReadLine(); From 5243342e1cb62f1a611eee60d52211adee628196 Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 24 Sep 2025 18:23:47 +0200 Subject: [PATCH 10/21] Dokoncenie konzoly. --- src/AppsLab-008-ConsoleReadLine/Program.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 05fc3d29..fbfa7056 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -3,13 +3,13 @@ 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($"Aha, mas teda {vek} rokov"); Console.WriteLine("Ake je tvoje oblubune jedlo?"); string jedlo = Console.ReadLine(); Console.WriteLine($"Hmmm, {jedlo} to znie skvele!"); -Console.WriteLine("Aky mas dns den?"); +Console.WriteLine("Aky mas dnes den?"); string den = Console.ReadLine(); -Console.WriteLine($"Tak to mas skvele!"); +Console.WriteLine("Tak to mas skvele!"); Console.WriteLine("Preco sa rozpravas s robotom?"); string text = Console.ReadLine(); Console.WriteLine("Nemyslis ze si na tom dost zle ked sa musis rozpavat so mnou?"); @@ -17,7 +17,11 @@ Console.WriteLine("Aka je tvoja oblubena farba?"); string farba = Console.ReadLine(); Console.WriteLine($"Hmm, {farba}? Ja poznam aj krajsie ale tak je to tvoja vec. Kazdemu sa paci nieco ine."); -Console.WriteLine($"Tak, to by bolo zatial vsetko. Pokracovanie nabuduce."); +Console.WriteLine("Stlac klavesu: "); +var key = Console.ReadKey(); +Console.WriteLine(); +Console.WriteLine($"Stlacili ste klavesu: {key.KeyChar}"); Console.WriteLine("Kolko dostanem cash za tento projekt?"); string text2= Console.ReadLine(); -Console.WriteLine("Tak neni to moc ale na zaciatok staci!"); \ No newline at end of file +Console.WriteLine("Tak neni to moc ale na zaciatok staci!"); +Console.WriteLine($"Tak, to by bolo zatial vsetko. Pokracovanie nabuduce."); From 4672a903b78e95ddbb0ccf83867b2b2cc599e8cb Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 24 Sep 2025 19:00:12 +0200 Subject: [PATCH 11/21] Koniec konzoly. --- src/AppsLab-008-ConsoleReadLine/Program.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index fbfa7056..5252d853 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -24,4 +24,5 @@ Console.WriteLine("Kolko dostanem cash za tento projekt?"); string text2= Console.ReadLine(); Console.WriteLine("Tak neni to moc ale na zaciatok staci!"); -Console.WriteLine($"Tak, to by bolo zatial vsetko. Pokracovanie nabuduce."); +Console.WriteLine($"Tak, to by bolo zatial vsetko."); +Console.WriteLine("Pokracovanie nabuduce"); From 336861866d9f27292ee76445eaac6e1a774bd260 Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 1 Oct 2025 17:42:59 +0200 Subject: [PATCH 12/21] Urobil som kalkulacku. --- AppsLab.CSharp.Exercises.sln | 35 ++++++----- ConsoleApp1/ConsoleApp1.csproj | 10 ++++ ConsoleApp2/ConsoleApp2.csproj | 10 ++++ ConsoleApp2/Program.cs | 29 +++++++++ src/AppsLab-008-ConsoleReadLine/Program.cs | 70 +++++++++++++--------- src/AppsLab-009-Operators/Calculator.cs | 27 ++++----- 6 files changed, 124 insertions(+), 57 deletions(-) create mode 100644 ConsoleApp1/ConsoleApp1.csproj create mode 100644 ConsoleApp2/ConsoleApp2.csproj create mode 100644 ConsoleApp2/Program.cs diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index 58bbf6b5..e073c685 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}") = "ConsoleApp2", "ConsoleApp2\ConsoleApp2.csproj", "{18E65813-FB33-4C61-AAA7-8138DE19DE2A}" +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 + {18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Debug|x64.ActiveCfg = Debug|Any CPU + {18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Debug|x64.Build.0 = Debug|Any CPU + {18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Debug|x86.ActiveCfg = Debug|Any CPU + {18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Debug|x86.Build.0 = Debug|Any CPU + {18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Release|Any CPU.Build.0 = Release|Any CPU + {18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Release|x64.ActiveCfg = Release|Any CPU + {18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Release|x64.Build.0 = Release|Any CPU + {18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Release|x86.ActiveCfg = Release|Any CPU + {18E65813-FB33-4C61-AAA7-8138DE19DE2A}.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 +682,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 = {0463079C-E8B4-4F31-9B34-80769936C76B} + EndGlobalSection EndGlobal diff --git a/ConsoleApp1/ConsoleApp1.csproj b/ConsoleApp1/ConsoleApp1.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/ConsoleApp1/ConsoleApp1.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/ConsoleApp2/ConsoleApp2.csproj b/ConsoleApp2/ConsoleApp2.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/ConsoleApp2/ConsoleApp2.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/ConsoleApp2/Program.cs b/ConsoleApp2/Program.cs new file mode 100644 index 00000000..dd44d8cd --- /dev/null +++ b/ConsoleApp2/Program.cs @@ -0,0 +1,29 @@ + +// nacitam prve cislo (konverziu na cislo) +// nacitam operaciu (nacitam ako string) +// nacitam druhe cislo (konverziu na cislo) +// vykonam operaciu +// vypisem vysledok + +Console.WriteLine("Vitaj v kalkulacke"); +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 vyskedok = operacia switch +{ + "+" => (cislo1 + cislo2), + "-" => (cislo1 - cislo2), + "*" => (cislo1 * cislo2), + "/" => (cislo1 / cislo2), + "%" => (cislo1 % cislo2), +}; +Console.WriteLine($"Vysledok je: {vyskedok}"); +Console.WriteLine("Stlac ENTER pre spustenie kalkulacky"); + + + + diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 5252d853..d93da41a 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -1,28 +1,42 @@ -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 {vek} rokov"); -Console.WriteLine("Ake je tvoje oblubune jedlo?"); -string jedlo = Console.ReadLine(); -Console.WriteLine($"Hmmm, {jedlo} to znie skvele!"); -Console.WriteLine("Aky mas dnes den?"); -string den = Console.ReadLine(); -Console.WriteLine("Tak to mas skvele!"); -Console.WriteLine("Preco sa rozpravas s robotom?"); -string text = Console.ReadLine(); -Console.WriteLine("Nemyslis ze si na tom dost zle ked sa musis rozpavat so mnou?"); -string text1 = Console.ReadLine(); -Console.WriteLine("Aka je tvoja oblubena farba?"); -string farba = Console.ReadLine(); -Console.WriteLine($"Hmm, {farba}? Ja poznam aj krajsie ale tak je to tvoja vec. Kazdemu sa paci nieco ine."); -Console.WriteLine("Stlac klavesu: "); -var key = Console.ReadKey(); -Console.WriteLine(); -Console.WriteLine($"Stlacili ste klavesu: {key.KeyChar}"); -Console.WriteLine("Kolko dostanem cash za tento projekt?"); -string text2= Console.ReadLine(); -Console.WriteLine("Tak neni to moc ale na zaciatok staci!"); -Console.WriteLine($"Tak, to by bolo zatial vsetko."); -Console.WriteLine("Pokracovanie nabuduce"); +Console.WriteLine("Vitaj v k alkulacke. Dnes budeme robit s cislami."); + +//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: {sucet}"); +// + + + + +//int a = 5; +//int b = 3; + + +//int sucet = a + b; // 8 +//int rozdiel = a - b; // 2 +//int nasobok = a * b; // 15 +//int podiel = a / b; // 1 +//int zvysok = a % b; //2 + +//int rovnost = a == b; // false +//int nerovnost = a != b; // true +//int vacsie ako = a > b; // true +//int mensie ako = a < b; // false +//int vacsieAleboRovne = a >= b; // true +//int mensieAleboRovne = a<= b; // false + + + + + + + + diff --git a/src/AppsLab-009-Operators/Calculator.cs b/src/AppsLab-009-Operators/Calculator.cs index 981993a9..f0693029 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,30 +66,29 @@ public bool AreNotEqual(int a, int b) /// public bool IsGreater(int a, int b) { - throw new NotImplementedException(); + return a > b; } /// /// This method returns true if the first integer is lesser than the second. /// - public bool IsLesser(int a, int b) + public bool IsLesser (int a, int b) { - throw new NotImplementedException(); + return a < b; } /// /// This method returns true if the first integer is greater than or equal to the second. /// - public bool IsGreaterOrEqual(int a, int b) + public bool IsGreaterOrEqual (int a, int b ) { - throw new NotImplementedException(); + return a >= b; } - /// /// This method returns true if the first integer is lesser than or equal to the second. /// public bool IsLesserOrEqual(int a, int b) { - throw new NotImplementedException(); + return a <= b; } } From 5dac39f654ea050defee31fc4394293a38c688a8 Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 8 Oct 2025 10:57:36 +0200 Subject: [PATCH 13/21] Urobil som kalkulacku 2 --- ConsoleApp2/Program.cs | 28 +++++++++++---------------- ConsoleApp3/ConsoleApp3.csproj | 10 ++++++++++ ConsoleApp3/Program.cs | 17 ++++++++++++++++ ConsoleApp4/ConsoleApp4.csproj | 10 ++++++++++ ConsoleApp4/Program.cs | 18 +++++++++++++++++ src/AppsLab-014-Switch/MovieRating.cs | 19 ++++++++++++++++-- 6 files changed, 83 insertions(+), 19 deletions(-) create mode 100644 ConsoleApp3/ConsoleApp3.csproj create mode 100644 ConsoleApp3/Program.cs create mode 100644 ConsoleApp4/ConsoleApp4.csproj create mode 100644 ConsoleApp4/Program.cs diff --git a/ConsoleApp2/Program.cs b/ConsoleApp2/Program.cs index dd44d8cd..8de3681c 100644 --- a/ConsoleApp2/Program.cs +++ b/ConsoleApp2/Program.cs @@ -1,5 +1,4 @@ - -// nacitam prve cislo (konverziu na cislo) +// nacitam prve cislo (konverziu na cislo) // nacitam operaciu (nacitam ako string) // nacitam druhe cislo (konverziu na cislo) // vykonam operaciu @@ -7,23 +6,18 @@ Console.WriteLine("Vitaj v kalkulacke"); 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(); -int vyskedok = operacia switch +int vysledok = operacia switch { - "+" => (cislo1 + cislo2), - "-" => (cislo1 - cislo2), - "*" => (cislo1 * cislo2), - "/" => (cislo1 / cislo2), - "%" => (cislo1 % cislo2), -}; -Console.WriteLine($"Vysledok je: {vyskedok}"); -Console.WriteLine("Stlac ENTER pre spustenie kalkulacky"); - - - - + "+" => (int)(cislo1 + cislo2), + "-" => (int)(cislo1 - cislo2), + "*" => (int)(cislo1 * cislo2), + "/" => (int)(cislo1 / cislo2), + "%" => (int)(cislo1 % cislo2), + _ => throw new Exception("Neznamy operator") +}; \ No newline at end of file diff --git a/ConsoleApp3/ConsoleApp3.csproj b/ConsoleApp3/ConsoleApp3.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/ConsoleApp3/ConsoleApp3.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/ConsoleApp3/Program.cs b/ConsoleApp3/Program.cs new file mode 100644 index 00000000..83092b4c --- /dev/null +++ b/ConsoleApp3/Program.cs @@ -0,0 +1,17 @@ +string text = "quarty"; +taxt = "iny text"; +text += "dalsi text"; + +int vek = 5; +int vek1 = 10; +vek = 15; +vek += 5; + +if (vek > 18) +{ + Console.WriteLine("Si dospely"); +} +else +{ + Console.WriteLine("Som dieta "); +} \ No newline at end of file diff --git a/ConsoleApp4/ConsoleApp4.csproj b/ConsoleApp4/ConsoleApp4.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/ConsoleApp4/ConsoleApp4.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/ConsoleApp4/Program.cs b/ConsoleApp4/Program.cs new file mode 100644 index 00000000..2da0b00f --- /dev/null +++ b/ConsoleApp4/Program.cs @@ -0,0 +1,18 @@ + +string text = "quarty"; +taxt = "iny text"; +text += "dalsi text"; + +int vek = 5; +int vek1 = 10; +vek = 15; +vek += 5; + +if (vek > 18) +{ + Console.WriteLine("Si dospely"); +} +else +{ + Console.WriteLine("Som dieta "); +} \ No newline at end of file diff --git a/src/AppsLab-014-Switch/MovieRating.cs b/src/AppsLab-014-Switch/MovieRating.cs index ab689d49..2d65f702 100644 --- a/src/AppsLab-014-Switch/MovieRating.cs +++ b/src/AppsLab-014-Switch/MovieRating.cs @@ -12,6 +12,21 @@ 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 +} + \ No newline at end of file From 5b15e9c7f426739e69a8182ce37fabf6827e1011 Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Sun, 12 Oct 2025 17:21:46 +0200 Subject: [PATCH 14/21] Urobil som 15 ulohu. --- ConsoleApp2/Program.cs | 36 ++++++------- src/AppsLab-008-ConsoleReadLine/Program.cs | 59 +++++++--------------- src/AppsLab-015-Arrays/ArrayProcessor.cs | 27 ++++++++-- 3 files changed, 54 insertions(+), 68 deletions(-) diff --git a/ConsoleApp2/Program.cs b/ConsoleApp2/Program.cs index 8de3681c..fe91c201 100644 --- a/ConsoleApp2/Program.cs +++ b/ConsoleApp2/Program.cs @@ -1,23 +1,17 @@ -// nacitam prve cislo (konverziu na cislo) -// nacitam operaciu (nacitam ako string) -// nacitam druhe cislo (konverziu na cislo) -// vykonam operaciu -// vypisem vysledok +string[] names = new string[] { "Michal", "Matej", "Alex", "David", "Eva" }; +string[,] matrix = new string [ 30, 5 ]; +matrix [0, 2] = "Michal"; +matrix [1, 2] = "Matej"; +matrix [25, 4] = "Alex"; +matrix [29, 0] = "David"; +for (int i =0; i < 30; i++) +{ + for (int j = 0; j < 5; j++) + { + Console.WriteLine(matrix [i, j] + ", "); + } + Console.WriteLine(); +} + -Console.WriteLine("Vitaj v kalkulacke"); -Console.WriteLine("Zadaj prve cislo: "); -decimal cislo1 = decimal.Parse(Console.ReadLine()); -Console.WriteLine("Zadaj druhe cislo: "); -decimal cislo2 = decimal.Parse(Console.ReadLine()); -Console.WriteLine("Zadaj operaciu (+,-,*,/,%):"); -string operacia = Console.ReadLine(); -int vysledok = operacia switch -{ - "+" => (int)(cislo1 + cislo2), - "-" => (int)(cislo1 - cislo2), - "*" => (int)(cislo1 * cislo2), - "/" => (int)(cislo1 / cislo2), - "%" => (int)(cislo1 % cislo2), - _ => throw new Exception("Neznamy operator") -}; \ No newline at end of file diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index d93da41a..448f4698 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -1,42 +1,17 @@ -Console.WriteLine("Vitaj v k alkulacke. Dnes budeme robit s cislami."); - -//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: {sucet}"); -// - - - - -//int a = 5; -//int b = 3; - - -//int sucet = a + b; // 8 -//int rozdiel = a - b; // 2 -//int nasobok = a * b; // 15 -//int podiel = a / b; // 1 -//int zvysok = a % b; //2 - -//int rovnost = a == b; // false -//int nerovnost = a != b; // true -//int vacsie ako = a > b; // true -//int mensie ako = a < b; // false -//int vacsieAleboRovne = a >= b; // true -//int mensieAleboRovne = a<= b; // false - - - - - - - - +Console.WriteLine("Vitaj v kalkulacke"); +Console.WriteLine("Zadaj prve cislo: "); +decimal cislo1 = decimal.Parse(Console.ReadLine()); +Console.WriteLine("Zadaj druhe cislo: "); +decimal cislo2 = decimal.Parse(Console.ReadLine()); +Console.WriteLine("Zadaj operaciu (+,-,*,/,%):"); +string operacia = Console.ReadLine(); + +int vysledok = operacia switch +{ + "+" => (int)(cislo1 + cislo2), + "-" => (int)(cislo1 - cislo2), + "*" => (int)(cislo1 * cislo2), + "/" => (int)(cislo1 / cislo2), + "%" => (int)(cislo1 % cislo2), + _ => throw new Exception("Neznamy operator") +}; \ No newline at end of file diff --git a/src/AppsLab-015-Arrays/ArrayProcessor.cs b/src/AppsLab-015-Arrays/ArrayProcessor.cs index 59f8d1c7..8757b91a 100644 --- a/src/AppsLab-015-Arrays/ArrayProcessor.cs +++ b/src/AppsLab-015-Arrays/ArrayProcessor.cs @@ -1,4 +1,6 @@ -namespace AppsLab_015_Arrays; +using System.Security.Cryptography; + +namespace AppsLab_015_Arrays; /// /// Class ArrayProcessor provides methods for working with integer arrays. @@ -13,7 +15,12 @@ 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]; + } /// @@ -24,7 +31,12 @@ 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 +48,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) + { + return 0; + } + return numbers[position]; + } /// @@ -46,6 +63,6 @@ public int GetElementAtPosition(int[] numbers, int position) /// Length of the array. public int GetLength(int[] numbers) { - throw new NotImplementedException(); + return numbers.Length; } } From 3d3a170512bc0d9a6389c97490bdf115a91d009b Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 15 Oct 2025 13:00:12 +0200 Subject: [PATCH 15/21] Urobil som ulohu 18. --- AppsLab.CSharp.Exercises.sln | 14 +++ ConsoleApp5/ConsoleApp5.csproj | 10 +++ ConsoleApp5/Program.cs | 89 +++++++++++++++++++ src/AppsLab-011-Strings/StringManipulator.cs | 23 +++-- src/AppsLab-016-Loops/WeatherStats.cs | 27 +++++- .../StringManipulatorTests.cs | 8 ++ 6 files changed, 160 insertions(+), 11 deletions(-) create mode 100644 ConsoleApp5/ConsoleApp5.csproj create mode 100644 ConsoleApp5/Program.cs diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index e073c685..aab622e4 100644 --- a/AppsLab.CSharp.Exercises.sln +++ b/AppsLab.CSharp.Exercises.sln @@ -95,6 +95,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppsLab-034-Debug", "src\Ap EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp2", "ConsoleApp2\ConsoleApp2.csproj", "{18E65813-FB33-4C61-AAA7-8138DE19DE2A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp5", "ConsoleApp5\ConsoleApp5.csproj", "{729F75F3-6059-468C-A4EE-4412B1F8BC25}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -633,6 +635,18 @@ Global {18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Release|x64.Build.0 = Release|Any CPU {18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Release|x86.ActiveCfg = Release|Any CPU {18E65813-FB33-4C61-AAA7-8138DE19DE2A}.Release|x86.Build.0 = Release|Any CPU + {729F75F3-6059-468C-A4EE-4412B1F8BC25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {729F75F3-6059-468C-A4EE-4412B1F8BC25}.Debug|Any CPU.Build.0 = Debug|Any CPU + {729F75F3-6059-468C-A4EE-4412B1F8BC25}.Debug|x64.ActiveCfg = Debug|Any CPU + {729F75F3-6059-468C-A4EE-4412B1F8BC25}.Debug|x64.Build.0 = Debug|Any CPU + {729F75F3-6059-468C-A4EE-4412B1F8BC25}.Debug|x86.ActiveCfg = Debug|Any CPU + {729F75F3-6059-468C-A4EE-4412B1F8BC25}.Debug|x86.Build.0 = Debug|Any CPU + {729F75F3-6059-468C-A4EE-4412B1F8BC25}.Release|Any CPU.ActiveCfg = Release|Any CPU + {729F75F3-6059-468C-A4EE-4412B1F8BC25}.Release|Any CPU.Build.0 = Release|Any CPU + {729F75F3-6059-468C-A4EE-4412B1F8BC25}.Release|x64.ActiveCfg = Release|Any CPU + {729F75F3-6059-468C-A4EE-4412B1F8BC25}.Release|x64.Build.0 = Release|Any CPU + {729F75F3-6059-468C-A4EE-4412B1F8BC25}.Release|x86.ActiveCfg = Release|Any CPU + {729F75F3-6059-468C-A4EE-4412B1F8BC25}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ConsoleApp5/ConsoleApp5.csproj b/ConsoleApp5/ConsoleApp5.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/ConsoleApp5/ConsoleApp5.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/ConsoleApp5/Program.cs b/ConsoleApp5/Program.cs new file mode 100644 index 00000000..d3154f67 --- /dev/null +++ b/ConsoleApp5/Program.cs @@ -0,0 +1,89 @@ +/* +string i = "*"; +while (i.Length < 6) +{ + Console.WriteLine(i); + i = "*"; +} +string j = "*****"; +while (j.Length > 0) +{ + Console.WriteLine(j); + j = j.Substring(0, j.Length -1); +} +*/ + + +/* +int[] cislo = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; +int i = 0; +int vysledok = 0; +for (i = 0; i < cislo.Length; i++) +{ + vysledok += cislo[i]; +} +Console.WriteLine(vysledok); +*/ + + +/* +string[] names = { "Dnes", "sa", "mam", "dobre" }; +foreach (string name in names) +{ + Console.Write($" {name} "); +*/ + + +/* +List numbers = new List(); +Console.WriteLine("Zadaj cislo"); +string vstup = Console.ReadLine(); + +while (vstup != "+") +{ + numbers.Add(int.Parse(vstup)); + Console.WriteLine("Zadaj cislo"); + vstup = Console.ReadLine(); +} + + Console.WriteLine("Vysledok scitania:"); + int sucet = 0; + foreach (int i in numbers) + { + sucet += i; + } + Console.WriteLine(sucet); +*/ + + +/* +Console.WriteLine("Zadaj svoje meno"); +string meno = Console.ReadLine(); +Console.WriteLine("Zadaj svoj vek"); +string vek =Console.ReadLine(); +*/ + +string meno = ZiskajMeno(); +string vek = ZiskajVek(); + +VypisUdaje(meno, vek); + +string ZiskajMeno() +{ + Console.WriteLine("Zadaj meno"); + string meno = Console.ReadLine(); + return meno; +} + + +string ZiskajVek() +{ + Console.WriteLine("Zadaj vek"); + string vek = Console.ReadLine(); + return vek; +} + +void VypisUdaje(string meno, string vek) +{ + Console.WriteLine($"Ahoj {meno}, tvoj vek je {vek} rokov."); +} \ No newline at end of file diff --git a/src/AppsLab-011-Strings/StringManipulator.cs b/src/AppsLab-011-Strings/StringManipulator.cs index f226d70d..c3ab2536 100644 --- a/src/AppsLab-011-Strings/StringManipulator.cs +++ b/src/AppsLab-011-Strings/StringManipulator.cs @@ -1,4 +1,7 @@ -namespace AppsLab_011_Strings; +using System.Reflection.Metadata.Ecma335; +using System.Security.Cryptography.X509Certificates; + +namespace AppsLab_011_Strings; /// /// Provides methods for manipulating strings. @@ -13,9 +16,8 @@ public class StringManipulator /// The concatenated string. public string AppendStrings(string first, string second) { - throw new NotImplementedException(); + return first + second; } - /// /// Converts a string to uppercase. /// @@ -23,7 +25,7 @@ public string AppendStrings(string first, string second) /// The uppercase string. public string ConvertToUpper(string input) { - throw new NotImplementedException(); + return input.ToUpper(); } /// @@ -33,7 +35,7 @@ public string ConvertToUpper(string input) /// The lowercase string. public string ConvertToLower(string input) { - throw new NotImplementedException(); + return input.ToLower(); } /// @@ -44,9 +46,8 @@ 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); } - /// /// Determines if a string starts with a substring. /// @@ -55,6 +56,12 @@ 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); + } + + + public string BezMedzier(string input) + { + return input.Train(); } } \ No newline at end of file diff --git a/src/AppsLab-016-Loops/WeatherStats.cs b/src/AppsLab-016-Loops/WeatherStats.cs index 8bca9659..e3910c48 100644 --- a/src/AppsLab-016-Loops/WeatherStats.cs +++ b/src/AppsLab-016-Loops/WeatherStats.cs @@ -12,7 +12,12 @@ public class WeatherStats /// Average temperature. public double AverageTemperature(double[] temperatures) { - throw new NotImplementedException(); + double sum = 0; + foreach (double temperature in temperatures) + { + sum += temperature; + } + return sum / temperatures.Length; } /// @@ -22,7 +27,15 @@ public double AverageTemperature(double[] temperatures) /// Maximum temperature. public double MaxTemperature(double[] temperatures) { - throw new NotImplementedException(); + double maximum = double.MinValue; + foreach (double temperature in temperatures) + { + if (temperature > maximum) + { + maximum = temperature; + } + } + return maximum; } /// @@ -32,6 +45,14 @@ public double MaxTemperature(double[] temperatures) /// Minimum temperature. public double MinTemperature(double[] temperatures) { - throw new NotImplementedException(); + double minimum = double.MaxValue; + foreach (double temperature in temperatures) + { + if (temperature < minimum) + { + minimum = temperature; + } + } + return minimum; } } diff --git a/tests/AppsLab-011-Strings.Tests/StringManipulatorTests.cs b/tests/AppsLab-011-Strings.Tests/StringManipulatorTests.cs index a1efacac..3fe429fb 100644 --- a/tests/AppsLab-011-Strings.Tests/StringManipulatorTests.cs +++ b/tests/AppsLab-011-Strings.Tests/StringManipulatorTests.cs @@ -85,4 +85,12 @@ public void StartsWithSubstring_DoesNotStartWithSubstring() var result = _stringManipulator.StartsWithSubstring("Hello World", "Goodbye"); Assert.That(result, Is.False, "The string starts with the substring when it should not."); } + [Test] + public void StirngJeBezMedzier() + { + var result = _stringManipulator.BezMedzier(" Hello World "); + Assert.That(result == " Hello World"); + } + + } } \ No newline at end of file From a847017479e1112bb2d15cb8e350530454551838 Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Sun, 19 Oct 2025 14:25:37 +0200 Subject: [PATCH 16/21] Urobil som moju 1. hru. --- AppsLab.CSharp.Exercises.sln | 14 ++ ConsoleApp5/Program.cs | 6 +- ConsoleApp6/ConsoleApp6.csproj | 10 + ConsoleApp6/Program.cs | 332 +++++++++++++++++++++++++++++++++ 4 files changed, 361 insertions(+), 1 deletion(-) create mode 100644 ConsoleApp6/ConsoleApp6.csproj create mode 100644 ConsoleApp6/Program.cs diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index aab622e4..0e32d113 100644 --- a/AppsLab.CSharp.Exercises.sln +++ b/AppsLab.CSharp.Exercises.sln @@ -97,6 +97,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp2", "ConsoleApp2\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp5", "ConsoleApp5\ConsoleApp5.csproj", "{729F75F3-6059-468C-A4EE-4412B1F8BC25}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp6", "ConsoleApp6\ConsoleApp6.csproj", "{6E24BADC-FEDA-419D-9A99-5444A95D728D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -647,6 +649,18 @@ Global {729F75F3-6059-468C-A4EE-4412B1F8BC25}.Release|x64.Build.0 = Release|Any CPU {729F75F3-6059-468C-A4EE-4412B1F8BC25}.Release|x86.ActiveCfg = Release|Any CPU {729F75F3-6059-468C-A4EE-4412B1F8BC25}.Release|x86.Build.0 = Release|Any CPU + {6E24BADC-FEDA-419D-9A99-5444A95D728D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6E24BADC-FEDA-419D-9A99-5444A95D728D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6E24BADC-FEDA-419D-9A99-5444A95D728D}.Debug|x64.ActiveCfg = Debug|Any CPU + {6E24BADC-FEDA-419D-9A99-5444A95D728D}.Debug|x64.Build.0 = Debug|Any CPU + {6E24BADC-FEDA-419D-9A99-5444A95D728D}.Debug|x86.ActiveCfg = Debug|Any CPU + {6E24BADC-FEDA-419D-9A99-5444A95D728D}.Debug|x86.Build.0 = Debug|Any CPU + {6E24BADC-FEDA-419D-9A99-5444A95D728D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6E24BADC-FEDA-419D-9A99-5444A95D728D}.Release|Any CPU.Build.0 = Release|Any CPU + {6E24BADC-FEDA-419D-9A99-5444A95D728D}.Release|x64.ActiveCfg = Release|Any CPU + {6E24BADC-FEDA-419D-9A99-5444A95D728D}.Release|x64.Build.0 = Release|Any CPU + {6E24BADC-FEDA-419D-9A99-5444A95D728D}.Release|x86.ActiveCfg = Release|Any CPU + {6E24BADC-FEDA-419D-9A99-5444A95D728D}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ConsoleApp5/Program.cs b/ConsoleApp5/Program.cs index d3154f67..e2212e86 100644 --- a/ConsoleApp5/Program.cs +++ b/ConsoleApp5/Program.cs @@ -31,6 +31,7 @@ foreach (string name in names) { Console.Write($" {name} "); +} */ @@ -63,6 +64,8 @@ string vek =Console.ReadLine(); */ + +/* string meno = ZiskajMeno(); string vek = ZiskajVek(); @@ -86,4 +89,5 @@ string ZiskajVek() void VypisUdaje(string meno, string vek) { Console.WriteLine($"Ahoj {meno}, tvoj vek je {vek} rokov."); -} \ No newline at end of file +} +*/ diff --git a/ConsoleApp6/ConsoleApp6.csproj b/ConsoleApp6/ConsoleApp6.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/ConsoleApp6/ConsoleApp6.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/ConsoleApp6/Program.cs b/ConsoleApp6/Program.cs new file mode 100644 index 00000000..48461a85 --- /dev/null +++ b/ConsoleApp6/Program.cs @@ -0,0 +1,332 @@ + +// uvod +Console.WriteLine("Vitaj v mojej prvej hre!"); +Console.WriteLine("Ide o to, ze bude tvoj charakter bojovat s priserami."); +Console.WriteLine("Ked nejaku zabijes tak dostanes veci v inventary ktore mozes pouzit. No vzdy si mozes vybrat len 1 vec!"); +Console.WriteLine("Mozes si vybrat: Hp potion na 5 sekund ( 10% viac zivota) alebo mec (dava 5% viac damage)."); +Console.WriteLine("Veci v inventari sa nepocitaju do vlasnosti postavy, ale mozes ich pouzit v boji LEN V 1. UTOKU!"); +Console.WriteLine("Ak chces pouzit vec z inventara, napis jej meno presne ako je v zozname!"); +Console.WriteLine($"Veci v inventari su: 'Hp potion' a 'Mec'."); +Console.WriteLine("Ak chces pokracovat bez pouzitia veci, napis 'nic'."); +// + + +//vlasnosti +Console.WriteLine("Zadaj meno svojho charakteru: "); +string meno = Console.ReadLine(); +int sila = 30; +int zivot = 90; +Console.WriteLine($"Tvoj charakter sa vola {meno}, ma silu {sila} a zivot {zivot}."); +Console.WriteLine("Zadaj meno nepriatela: "); +string nepriatelMeno = Console.ReadLine(); +int nepriatelSila = 20; +int nepriatelZivot = 60; +Console.WriteLine($"Tvoj nepriatel sa vola {nepriatelMeno}, ma silu {nepriatelSila} a zivot {nepriatelZivot}. "); +Console.WriteLine("Takze ideme na to!"); +// + + +// prva arena +while (zivot > 0 && nepriatelZivot > 0) + { + Console.WriteLine("Stlac enter pre spustenie utoku!"); + Console.ReadLine(); + Console.WriteLine($"{nepriatelMeno} zautocil na teba a zranil ta o {nepriatelSila} zivotov."); + zivot -= nepriatelSila; + if (zivot < 0) zivot = 0; + Console.WriteLine($"Tvoj zivot je teraz {zivot}. "); + if (zivot <= 0) + { + Console.WriteLine("Prehral si!"); + break; + } + Console.WriteLine($"Stlac enter aby {meno} zautocil na {nepriatelMeno}!"); + Console.ReadLine(); + Console.WriteLine($"{meno} zautocil na {nepriatelMeno} a zranil si ho o {sila} zivotov."); + nepriatelZivot -= sila; + if (nepriatelZivot < 0) nepriatelZivot = 0; + Console.WriteLine($"Zivot {nepriatelMeno} je teraz {nepriatelZivot}."); + if (nepriatelZivot <= 0) + { + Console.WriteLine($"Porazil si {nepriatelMeno} a postupujes do 2. areny!"); + } + } +// + + +//pouzitie inventara v 1. arene +List inventar = new List(); +Console.WriteLine("Ak chces otvorit inventar tak napis : M; a ak inventar nechces tak napis : K."); +string InvOpen = (Console.ReadLine()); +if (InvOpen.ToString().ToUpper() == "M") +{ + Console.WriteLine("Inventar mas pazdny; ak chces nieco dostat tak musis vyhrat boj!"); +} +else if (InvOpen.ToString().ToUpper() == "K") +{ + Console.WriteLine("Pokračujes bez použitia inventara."); +} +else +{ + Console.WriteLine("Zadal si zlu klavesu, skus to znova!"); + InvOpen = (Console.ReadLine()); +} + + + + + // + + + //pouzitie potionu v 1. arene + if (inventar.Contains("Hp potion")) +{ + Console.WriteLine("Chces pouzit Hp potion? Ak ano napis : YES; ak nie napis : NO."); + char pouzitPotion = char.Parse(Console.ReadLine()); + if (pouzitPotion.ToString().ToUpper() == "YES") + { + Console.WriteLine("Pouzil si Hp potion a tvoj zivot sa zvysil o 10% na 99 zivotov."); + inventar.Remove("Hp potion"); + inventar.Add("token zivota"); + } + else if (pouzitPotion.ToString().ToUpper() == "NO") + Console.WriteLine("Pokračujes bez použitia potionu."); + else + Console.WriteLine("Zadal si zle slovo, skus to znova!"); +} + +else if (InvOpen.ToString().ToUpper() == "K") + Console.WriteLine("Pokračujes bez použitia inventara."); + // + + + // pouzitie meca v 1. arene + if (inventar.Contains("Mec")) + { + Console.WriteLine("Chces pouzit Mec? Ak ano napis : YES; ak nie napis : NO."); + char pouzitMec = char.Parse(Console.ReadLine()); + if (pouzitMec.ToString().ToUpper() == "YES") + { + Console.WriteLine("Pouzil si Mec a tvoja sila sa zvysila o 5% na 33 sily."); + inventar.Remove("Mec"); + inventar.Add("token sily"); + } + else if (pouzitMec.ToString().ToUpper() == "NO") + Console.WriteLine("Pokračujes bez použitia meca."); + else + Console.WriteLine("Zadal si zle slovo, skus to znova!"); + } + // + + + // vlasnosti 2. areny + int sila1 = 30; + int zivot1 = 90; + Console.WriteLine($"{meno} ma silu {sila1} a zivot {zivot1}. "); + int nepriatelSila1 = 25; + int nepriatelZivot1 = 65; + Console.WriteLine($"{nepriatelMeno} ma silu {nepriatelSila1} a zivot {nepriatelZivot1}. "); + Console.WriteLine("Takze ideme na to!"); + // + + + //pouzitie inventara v 2. arene + List inventar1 = new List(); + Console.WriteLine("Ak chces otvorit inventar tak napis : M; a ak inventar nechces tak napis : K."); + string InvOpen1 = (Console.ReadLine()); + if (InvOpen1.ToString().ToUpper() == "M") + { + Console.WriteLine("Inventar mas pazdny; ak chces nieco dostat tak musis vyhrat boj!"); + } + else if (InvOpen1.ToString().ToUpper() == "K") + { + Console.WriteLine("Pokračujes bez použitia inventara."); +} +// + + +// druha arena +while (zivot1 > 0 && nepriatelZivot1 > 0) + { + Console.WriteLine("Stlac enter pre spustenie utoku!"); + Console.ReadLine(); + Console.WriteLine($"{nepriatelMeno} zautocil na teba a zranil ta o {nepriatelSila1} zivotov."); + zivot1 -= nepriatelSila1; + if (zivot1 < 0) zivot1 = 0; + Console.WriteLine($"Tvoj zivot je teraz {zivot1}. "); + if (zivot1 <= 0) + { + Console.WriteLine("Prehral si!"); + break; + } + Console.WriteLine($"Stlac enter aby {meno} zautocil na {nepriatelMeno}!"); + Console.ReadLine(); + Console.WriteLine($"{meno} zautocil na {nepriatelMeno} a zranil si ho o {sila1}."); + nepriatelZivot1 -= sila1; + if (nepriatelZivot1 < 0) nepriatelZivot1 = 0; + Console.WriteLine($"Zivot {nepriatelMeno} je teraz {nepriatelZivot1}."); + if (nepriatelZivot1 <= 0) + { + Console.WriteLine($"Porazil si {nepriatelMeno} a postupujes do 3. areny!"); + } + } + // + + + //pouzitie potionu v 2. arene + if (inventar.Contains("Hp potion")) + { + Console.WriteLine("Chces pouzit Hp potion? Ak ano napis : YES; ak nie napis : NO."); + char pouzitPotion = char.Parse(Console.ReadLine()); + if (pouzitPotion.ToString().ToUpper() == "YES") + { + Console.WriteLine("Pouzil si Hp potion a tvoj zivot sa zvysil o 10% na 99 zivotov."); + inventar.Remove("Hp potion"); + inventar.Add("token zivota"); + } + else if (pouzitPotion.ToString().ToUpper() == "NO") + Console.WriteLine("Pokračujes bez použitia potionu."); + else + Console.WriteLine("Zadal si zle slovo, skus to znova!"); + } + + else if (InvOpen.ToString().ToUpper() == "K") + Console.WriteLine("Pokračujes bez použitia inventara."); + // + + + // pouzitie meca v 2. arene + if (inventar.Contains("Mec")) + { + Console.WriteLine("Chces pouzit Mec? Ak ano napis : YES; ak nie napis : NO."); + char pouzitMec = char.Parse(Console.ReadLine()); + if (pouzitMec.ToString().ToUpper() == "YES") + { + Console.WriteLine("Pouzil si Mec a tvoja sila sa zvysila o 5% na 33 sily."); + inventar.Remove("Mec"); + inventar.Add("token sily"); + } + else if (pouzitMec.ToString().ToUpper() == "NO") + Console.WriteLine("Pokračujes bez použitia meca."); + else + Console.WriteLine("Zadal si zle slovo, skus to znova!"); + } + // + + + // nepouzil si nic v 2. arene + if (!inventar.Contains("Hp potion") && !inventar.Contains("Mec")) + { + Console.WriteLine("Pokračujes bez použitia inventara."); + } + // + + + //pouzitie inventara v 3. arene + List inventar2 = new List(); + Console.WriteLine("Ak chces otvorit inventar tak napis : M; a ak inventar nechces tak napis : K."); + char InvOpen2 = char.Parse(Console.ReadLine()); + if (InvOpen2.ToString().ToUpper() == "M") + { + Console.WriteLine("Inventar mas pazdny; ak chces nieco dostat tak musis vyhrat boj!"); + } + + else if (InvOpen2.ToString().ToUpper() == "K") + { + Console.WriteLine("Pokračujes bez použitia inventara."); + } + // + + + // vlasnosti 3. areny + int sila2 = 30; + int zivot2 = 90; + Console.WriteLine($"{meno} ma silu {sila2} a zivot {zivot2}. "); + int nepriatelSila2 = 28; + int nepriatelZivot2 = 75; + Console.WriteLine($"{nepriatelMeno} ma silu {nepriatelSila2} a zivot {nepriatelZivot2}. "); + Console.WriteLine("Takze ideme na to!"); + // + + + // tretia arena + while (zivot2 > 0 && nepriatelZivot2 > 0) + { + Console.WriteLine("Stlac enter pre spustenie utoku!"); + Console.ReadLine(); + Console.WriteLine($"{nepriatelMeno} zautocil na teba a zranil ta o {nepriatelSila2} zivotov."); + zivot2 -= nepriatelSila2; + if (zivot2 < 0) zivot2 = 0; + Console.WriteLine($"Tvoj zivot je teraz {zivot2}. "); + if (zivot2 <= 0) + { + Console.WriteLine("Prehral si!"); + break; + } + Console.WriteLine($"Stlac enter aby {meno} zautocil na {nepriatelMeno}"); + Console.ReadLine(); + Console.WriteLine($"{meno} zautocil na {nepriatelMeno} a zranil si ho o {sila2} zivotov"); + nepriatelZivot2 -= sila2; + if (nepriatelZivot2 < 0) nepriatelZivot2 = 0; + Console.WriteLine($"Zivot {nepriatelMeno} je teraz {nepriatelZivot2}"); + if (nepriatelZivot2 <= 0) + { + Console.WriteLine($"Porazil si {nepriatelMeno} a vyhral si hru! Gratulujem!"); + } + } + + + // bonusova aréna + Console.WriteLine("Gratulujem ze si vyhral hru! Ak chces pokracovat do bonusovej areny tak napis : Y; ak nie napis : N."); + Console.ReadLine(); + if (InvOpen2.ToString().ToUpper() == "Y") + Console.WriteLine("Pokračujes do bonusovej arény!"); + { + + Console.WriteLine("Vitaj v bonusovej arene!"); + Console.WriteLine("Tvoj nepriatel v bonusovej arene bude matematika!"); + Console.WriteLine("Tvojou ulohou je vyriesit 3 priklady spravne aby si vyhral bonusovu arenu!"); + int score = 0; + Console.WriteLine("Priklad 1: Kolko je 5 + 8 * 4 ?"); + int answer1 = int.Parse(Console.ReadLine()); + if (answer1 == 37) + { + score++; + Console.WriteLine("Spravne!"); + } + else + { + Console.WriteLine("Nespravne!"); + } + Console.WriteLine("Priklad 2: Kolko je (10 + 5) / 5 * 16 ?"); + int answer2 = int.Parse(Console.ReadLine()); + if (answer2 == 48) + { + score++; + Console.WriteLine("Spravne!"); + } + else + { + Console.WriteLine("Nespravne!"); + } + Console.WriteLine("Priklad 3: Kolko je 18 + 2 ?"); + int answer3 = int.Parse(Console.ReadLine()); + if (answer3 == 20) + { + score++; + Console.WriteLine("Spravne!"); + } + else + { + Console.WriteLine("Nespravne!"); + } + if (score == 3) + { + Console.WriteLine("Gratulujem! Vyriesil si vsetky priklady spravne a vyhral bonusovu arenu!"); + } + else + { + Console.WriteLine($"Vyriesil si {score} z 3 prikladov spravne. Skus to znova nabuduce!"); + } + } + From a0b8766daf7f66a83bf2d179680682842dc2c076 Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Sun, 19 Oct 2025 15:05:47 +0200 Subject: [PATCH 17/21] Upravil som moju 1. hru. --- ConsoleApp6/Program.cs | 71 ++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/ConsoleApp6/Program.cs b/ConsoleApp6/Program.cs index 48461a85..11ba48ff 100644 --- a/ConsoleApp6/Program.cs +++ b/ConsoleApp6/Program.cs @@ -24,6 +24,11 @@ Console.WriteLine($"Tvoj nepriatel sa vola {nepriatelMeno}, ma silu {nepriatelSila} a zivot {nepriatelZivot}. "); Console.WriteLine("Takze ideme na to!"); // +Console.WriteLine("Ak chces otvorit inventar tak napis : M; a ak inventar nechces tak napis : K."); +string InvOpen3 = (Console.ReadLine()); +Console.WriteLine("Inventar mas pazdny; ak chces nieco dostat tak musis vyhrat boj!"); +// + // prva arena @@ -60,7 +65,10 @@ string InvOpen = (Console.ReadLine()); if (InvOpen.ToString().ToUpper() == "M") { - Console.WriteLine("Inventar mas pazdny; ak chces nieco dostat tak musis vyhrat boj!"); + Console.WriteLine("Gratulujem.teraz si mozes vybrat vec z inventara."); + Console.WriteLine("Zadaj nazov veci ktoru chces pouzit: "); + string vec = Console.ReadLine(); + inventar.Add(vec); } else if (InvOpen.ToString().ToUpper() == "K") { @@ -81,15 +89,15 @@ //pouzitie potionu v 1. arene if (inventar.Contains("Hp potion")) { - Console.WriteLine("Chces pouzit Hp potion? Ak ano napis : YES; ak nie napis : NO."); - char pouzitPotion = char.Parse(Console.ReadLine()); - if (pouzitPotion.ToString().ToUpper() == "YES") + Console.WriteLine("Chces pouzit Hp potion? Ak ano napis : Yes; ak nie napis : No."); + string pouzitPotion = (Console.ReadLine()); + if (pouzitPotion.ToString().ToUpper() == "Yes") { Console.WriteLine("Pouzil si Hp potion a tvoj zivot sa zvysil o 10% na 99 zivotov."); inventar.Remove("Hp potion"); inventar.Add("token zivota"); } - else if (pouzitPotion.ToString().ToUpper() == "NO") + else if (pouzitPotion.ToString().ToUpper() == "No") Console.WriteLine("Pokračujes bez použitia potionu."); else Console.WriteLine("Zadal si zle slovo, skus to znova!"); @@ -103,15 +111,15 @@ // pouzitie meca v 1. arene if (inventar.Contains("Mec")) { - Console.WriteLine("Chces pouzit Mec? Ak ano napis : YES; ak nie napis : NO."); - char pouzitMec = char.Parse(Console.ReadLine()); - if (pouzitMec.ToString().ToUpper() == "YES") + Console.WriteLine("Chces pouzit Mec? Ak ano napis : Yes; ak nie napis : No."); + string pouzitMec = (Console.ReadLine()); + if (pouzitMec.ToString().ToUpper() == "Yes") { Console.WriteLine("Pouzil si Mec a tvoja sila sa zvysila o 5% na 33 sily."); inventar.Remove("Mec"); inventar.Add("token sily"); } - else if (pouzitMec.ToString().ToUpper() == "NO") + else if (pouzitMec.ToString().ToUpper() == "No") Console.WriteLine("Pokračujes bez použitia meca."); else Console.WriteLine("Zadal si zle slovo, skus to znova!"); @@ -127,21 +135,30 @@ int nepriatelZivot1 = 65; Console.WriteLine($"{nepriatelMeno} ma silu {nepriatelSila1} a zivot {nepriatelZivot1}. "); Console.WriteLine("Takze ideme na to!"); - // +// - //pouzitie inventara v 2. arene - List inventar1 = new List(); - Console.WriteLine("Ak chces otvorit inventar tak napis : M; a ak inventar nechces tak napis : K."); - string InvOpen1 = (Console.ReadLine()); - if (InvOpen1.ToString().ToUpper() == "M") - { - Console.WriteLine("Inventar mas pazdny; ak chces nieco dostat tak musis vyhrat boj!"); - } - else if (InvOpen1.ToString().ToUpper() == "K") - { - Console.WriteLine("Pokračujes bez použitia inventara."); +//pouzitie inventara v 2. arene +List inventar1 = new List(); +Console.WriteLine("Ak chces otvorit inventar tak napis : M; a ak inventar nechces tak napis : K."); +string InvOpen1 = (Console.ReadLine()); +if (InvOpen1.ToString().ToUpper() == "M") +{ + Console.WriteLine("Gratulujem.teraz si mozes vybrat vec z inventara."); + Console.WriteLine("Zadaj nazov veci ktoru chces pouzit: "); + string vec = Console.ReadLine(); + inventar1.Add(vec); +} +else if (InvOpen1.ToString().ToUpper() == "K") +{ + Console.WriteLine("Pokračujes bez použitia inventara."); } +else +{ + Console.WriteLine("Zadal si zlu klavesu, skus to znova!"); + InvOpen1 = (Console.ReadLine()); +} + // @@ -176,15 +193,15 @@ //pouzitie potionu v 2. arene if (inventar.Contains("Hp potion")) { - Console.WriteLine("Chces pouzit Hp potion? Ak ano napis : YES; ak nie napis : NO."); + Console.WriteLine("Chces pouzit Hp potion? Ak ano napis : Yes; ak nie napis : No."); char pouzitPotion = char.Parse(Console.ReadLine()); - if (pouzitPotion.ToString().ToUpper() == "YES") + if (pouzitPotion.ToString().ToUpper() == "Yes") { Console.WriteLine("Pouzil si Hp potion a tvoj zivot sa zvysil o 10% na 99 zivotov."); inventar.Remove("Hp potion"); inventar.Add("token zivota"); } - else if (pouzitPotion.ToString().ToUpper() == "NO") + else if (pouzitPotion.ToString().ToUpper() == "No") Console.WriteLine("Pokračujes bez použitia potionu."); else Console.WriteLine("Zadal si zle slovo, skus to znova!"); @@ -198,15 +215,15 @@ // pouzitie meca v 2. arene if (inventar.Contains("Mec")) { - Console.WriteLine("Chces pouzit Mec? Ak ano napis : YES; ak nie napis : NO."); + Console.WriteLine("Chces pouzit Mec? Ak ano napis : Yes; ak nie napis : No."); char pouzitMec = char.Parse(Console.ReadLine()); - if (pouzitMec.ToString().ToUpper() == "YES") + if (pouzitMec.ToString().ToUpper() == "Yes") { Console.WriteLine("Pouzil si Mec a tvoja sila sa zvysila o 5% na 33 sily."); inventar.Remove("Mec"); inventar.Add("token sily"); } - else if (pouzitMec.ToString().ToUpper() == "NO") + else if (pouzitMec.ToString().ToUpper() == "No") Console.WriteLine("Pokračujes bez použitia meca."); else Console.WriteLine("Zadal si zle slovo, skus to znova!"); From fc2234bc304649c553ccd692a8de9a27db8b58cd Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 22 Oct 2025 16:39:42 +0200 Subject: [PATCH 18/21] Urobil som grafity. --- AppsLab.CSharp.Exercises.sln | 15 + ConsoleApp6/Program.cs | 300 +++++------ Grafiti/Grafiti.csproj | 10 + Grafiti/Program.cs | 954 +++++++++++++++++++++++++++++++++++ Grafitti/Grafitti.csproj | 10 + Grafitti/Program.cs | 2 + 6 files changed, 1141 insertions(+), 150 deletions(-) create mode 100644 Grafiti/Grafiti.csproj create mode 100644 Grafiti/Program.cs create mode 100644 Grafitti/Grafitti.csproj create mode 100644 Grafitti/Program.cs diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index 0e32d113..290abaff 100644 --- a/AppsLab.CSharp.Exercises.sln +++ b/AppsLab.CSharp.Exercises.sln @@ -99,6 +99,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp5", "ConsoleApp5\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp6", "ConsoleApp6\ConsoleApp6.csproj", "{6E24BADC-FEDA-419D-9A99-5444A95D728D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grafiti", "Grafiti\Grafiti.csproj", "{67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -661,6 +663,18 @@ Global {6E24BADC-FEDA-419D-9A99-5444A95D728D}.Release|x64.Build.0 = Release|Any CPU {6E24BADC-FEDA-419D-9A99-5444A95D728D}.Release|x86.ActiveCfg = Release|Any CPU {6E24BADC-FEDA-419D-9A99-5444A95D728D}.Release|x86.Build.0 = Release|Any CPU + {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}.Debug|x64.ActiveCfg = Debug|Any CPU + {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}.Debug|x64.Build.0 = Debug|Any CPU + {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}.Debug|x86.ActiveCfg = Debug|Any CPU + {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}.Debug|x86.Build.0 = Debug|Any CPU + {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}.Release|Any CPU.Build.0 = Release|Any CPU + {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}.Release|x64.ActiveCfg = Release|Any CPU + {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}.Release|x64.Build.0 = Release|Any CPU + {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}.Release|x86.ActiveCfg = Release|Any CPU + {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}.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} + {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A} = {56555FB0-B513-49EF-9002-A5AF135EA090} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0463079C-E8B4-4F31-9B34-80769936C76B} diff --git a/ConsoleApp6/Program.cs b/ConsoleApp6/Program.cs index 11ba48ff..ed5877f3 100644 --- a/ConsoleApp6/Program.cs +++ b/ConsoleApp6/Program.cs @@ -105,28 +105,26 @@ else if (InvOpen.ToString().ToUpper() == "K") Console.WriteLine("Pokračujes bez použitia inventara."); - // +// - // pouzitie meca v 1. arene - if (inventar.Contains("Mec")) +// pouzitie meca v 1. arene +if (inventar.Contains("Mec")) +{ + Console.WriteLine("Chces pouzit Mec? Ak ano napis : Yes; ak nie napis : No."); + string pouzitMec = (Console.ReadLine()); + if (pouzitMec.ToString().ToUpper() == "Yes") { - Console.WriteLine("Chces pouzit Mec? Ak ano napis : Yes; ak nie napis : No."); - string pouzitMec = (Console.ReadLine()); - if (pouzitMec.ToString().ToUpper() == "Yes") - { - Console.WriteLine("Pouzil si Mec a tvoja sila sa zvysila o 5% na 33 sily."); - inventar.Remove("Mec"); - inventar.Add("token sily"); - } - else if (pouzitMec.ToString().ToUpper() == "No") - Console.WriteLine("Pokračujes bez použitia meca."); - else - Console.WriteLine("Zadal si zle slovo, skus to znova!"); + Console.WriteLine("Pouzil si Mec a tvoja sila sa zvysila o 5% na 33 sily."); + inventar.Remove("Mec"); + inventar.Add("token sily"); } + else if (pouzitMec.ToString().ToUpper() == "No") + Console.WriteLine("Pokračujes bez použitia meca."); + // - + // vlasnosti 2. areny int sila1 = 30; int zivot1 = 90; @@ -135,35 +133,34 @@ int nepriatelZivot1 = 65; Console.WriteLine($"{nepriatelMeno} ma silu {nepriatelSila1} a zivot {nepriatelZivot1}. "); Console.WriteLine("Takze ideme na to!"); -// - - -//pouzitie inventara v 2. arene -List inventar1 = new List(); -Console.WriteLine("Ak chces otvorit inventar tak napis : M; a ak inventar nechces tak napis : K."); -string InvOpen1 = (Console.ReadLine()); -if (InvOpen1.ToString().ToUpper() == "M") -{ - Console.WriteLine("Gratulujem.teraz si mozes vybrat vec z inventara."); - Console.WriteLine("Zadaj nazov veci ktoru chces pouzit: "); - string vec = Console.ReadLine(); - inventar1.Add(vec); -} -else if (InvOpen1.ToString().ToUpper() == "K") -{ - Console.WriteLine("Pokračujes bez použitia inventara."); -} -else -{ - Console.WriteLine("Zadal si zlu klavesu, skus to znova!"); - InvOpen1 = (Console.ReadLine()); -} - -// + // + + //pouzitie inventara v 2. arene + List inventar1 = new List(); + Console.WriteLine("Ak chces otvorit inventar tak napis : M; a ak inventar nechces tak napis : K."); + string InvOpen1 = (Console.ReadLine()); + if (InvOpen1.ToString().ToUpper() == "M") + { + Console.WriteLine("Gratulujem.teraz si mozes vybrat vec z inventara."); + Console.WriteLine("Zadaj nazov veci ktoru chces pouzit: "); + string vec = Console.ReadLine(); + inventar1.Add(vec); + } + else if (InvOpen1.ToString().ToUpper() == "K") + { + Console.WriteLine("Pokračujes bez použitia inventara."); + } + else + { + Console.WriteLine("Zadal si zlu klavesu, skus to znova!"); + InvOpen1 = (Console.ReadLine()); + } + // + -// druha arena -while (zivot1 > 0 && nepriatelZivot1 > 0) + // druha arena + while (zivot1 > 0 && nepriatelZivot1 > 0) { Console.WriteLine("Stlac enter pre spustenie utoku!"); Console.ReadLine(); @@ -216,134 +213,137 @@ if (inventar.Contains("Mec")) { Console.WriteLine("Chces pouzit Mec? Ak ano napis : Yes; ak nie napis : No."); - char pouzitMec = char.Parse(Console.ReadLine()); - if (pouzitMec.ToString().ToUpper() == "Yes") + char pouzitMec1 = char.Parse(Console.ReadLine()); + if (pouzitMec1.ToString().ToUpper() == "Yes") { Console.WriteLine("Pouzil si Mec a tvoja sila sa zvysila o 5% na 33 sily."); inventar.Remove("Mec"); inventar.Add("token sily"); } - else if (pouzitMec.ToString().ToUpper() == "No") + else if (pouzitMec1.ToString().ToUpper() == "No") Console.WriteLine("Pokračujes bez použitia meca."); - else - Console.WriteLine("Zadal si zle slovo, skus to znova!"); - } - // - - - // nepouzil si nic v 2. arene - if (!inventar.Contains("Hp potion") && !inventar.Contains("Mec")) - { - Console.WriteLine("Pokračujes bez použitia inventara."); - } - // - - //pouzitie inventara v 3. arene - List inventar2 = new List(); - Console.WriteLine("Ak chces otvorit inventar tak napis : M; a ak inventar nechces tak napis : K."); - char InvOpen2 = char.Parse(Console.ReadLine()); - if (InvOpen2.ToString().ToUpper() == "M") - { - Console.WriteLine("Inventar mas pazdny; ak chces nieco dostat tak musis vyhrat boj!"); - } - - else if (InvOpen2.ToString().ToUpper() == "K") - { - Console.WriteLine("Pokračujes bez použitia inventara."); - } - // + // - // vlasnosti 3. areny - int sila2 = 30; - int zivot2 = 90; - Console.WriteLine($"{meno} ma silu {sila2} a zivot {zivot2}. "); - int nepriatelSila2 = 28; - int nepriatelZivot2 = 75; - Console.WriteLine($"{nepriatelMeno} ma silu {nepriatelSila2} a zivot {nepriatelZivot2}. "); - Console.WriteLine("Takze ideme na to!"); - // + // nepouzil si nic v 2. arene + if (!inventar.Contains("Hp potion") && !inventar.Contains("Mec")) + { + Console.WriteLine("Pokračujes bez použitia inventara."); + } + // - // tretia arena - while (zivot2 > 0 && nepriatelZivot2 > 0) - { - Console.WriteLine("Stlac enter pre spustenie utoku!"); - Console.ReadLine(); - Console.WriteLine($"{nepriatelMeno} zautocil na teba a zranil ta o {nepriatelSila2} zivotov."); - zivot2 -= nepriatelSila2; - if (zivot2 < 0) zivot2 = 0; - Console.WriteLine($"Tvoj zivot je teraz {zivot2}. "); - if (zivot2 <= 0) + //pouzitie inventara v 3. arene + List inventar2 = new List(); + Console.WriteLine("Ak chces otvorit inventar tak napis : M; a ak inventar nechces tak napis : K."); + char InvOpen2 = char.Parse(Console.ReadLine()); + if (InvOpen2.ToString().ToUpper() == "M") { - Console.WriteLine("Prehral si!"); - break; + Console.WriteLine("Inventar mas pazdny; ak chces nieco dostat tak musis vyhrat boj!"); } - Console.WriteLine($"Stlac enter aby {meno} zautocil na {nepriatelMeno}"); - Console.ReadLine(); - Console.WriteLine($"{meno} zautocil na {nepriatelMeno} a zranil si ho o {sila2} zivotov"); - nepriatelZivot2 -= sila2; - if (nepriatelZivot2 < 0) nepriatelZivot2 = 0; - Console.WriteLine($"Zivot {nepriatelMeno} je teraz {nepriatelZivot2}"); - if (nepriatelZivot2 <= 0) + + else if (InvOpen2.ToString().ToUpper() == "K") { - Console.WriteLine($"Porazil si {nepriatelMeno} a vyhral si hru! Gratulujem!"); + Console.WriteLine("Pokračujes bez použitia inventara."); } - } + // - // bonusova aréna - Console.WriteLine("Gratulujem ze si vyhral hru! Ak chces pokracovat do bonusovej areny tak napis : Y; ak nie napis : N."); - Console.ReadLine(); - if (InvOpen2.ToString().ToUpper() == "Y") - Console.WriteLine("Pokračujes do bonusovej arény!"); - { + // vlasnosti 3. areny + int sila2 = 30; + int zivot2 = 90; + Console.WriteLine($"{meno} ma silu {sila2} a zivot {zivot2}. "); + int nepriatelSila2 = 28; + int nepriatelZivot2 = 75; + Console.WriteLine($"{nepriatelMeno} ma silu {nepriatelSila2} a zivot {nepriatelZivot2}. "); + Console.WriteLine("Takze ideme na to!"); + // - Console.WriteLine("Vitaj v bonusovej arene!"); - Console.WriteLine("Tvoj nepriatel v bonusovej arene bude matematika!"); - Console.WriteLine("Tvojou ulohou je vyriesit 3 priklady spravne aby si vyhral bonusovu arenu!"); - int score = 0; - Console.WriteLine("Priklad 1: Kolko je 5 + 8 * 4 ?"); - int answer1 = int.Parse(Console.ReadLine()); - if (answer1 == 37) - { - score++; - Console.WriteLine("Spravne!"); - } - else - { - Console.WriteLine("Nespravne!"); - } - Console.WriteLine("Priklad 2: Kolko je (10 + 5) / 5 * 16 ?"); - int answer2 = int.Parse(Console.ReadLine()); - if (answer2 == 48) - { - score++; - Console.WriteLine("Spravne!"); - } - else - { - Console.WriteLine("Nespravne!"); - } - Console.WriteLine("Priklad 3: Kolko je 18 + 2 ?"); - int answer3 = int.Parse(Console.ReadLine()); - if (answer3 == 20) - { - score++; - Console.WriteLine("Spravne!"); - } - else - { - Console.WriteLine("Nespravne!"); - } - if (score == 3) + + // tretia arena + while (zivot2 > 0 && nepriatelZivot2 > 0) { - Console.WriteLine("Gratulujem! Vyriesil si vsetky priklady spravne a vyhral bonusovu arenu!"); + Console.WriteLine("Stlac enter pre spustenie utoku!"); + Console.ReadLine(); + Console.WriteLine($"{nepriatelMeno} zautocil na teba a zranil ta o {nepriatelSila2} zivotov."); + zivot2 -= nepriatelSila2; + if (zivot2 < 0) zivot2 = 0; + Console.WriteLine($"Tvoj zivot je teraz {zivot2}. "); + if (zivot2 <= 0) + { + Console.WriteLine("Prehral si!"); + break; + } + Console.WriteLine($"Stlac enter aby {meno} zautocil na {nepriatelMeno}"); + Console.ReadLine(); + Console.WriteLine($"{meno} zautocil na {nepriatelMeno} a zranil si ho o {sila2} zivotov"); + nepriatelZivot2 -= sila2; + if (nepriatelZivot2 < 0) nepriatelZivot2 = 0; + Console.WriteLine($"Zivot {nepriatelMeno} je teraz {nepriatelZivot2}"); + if (nepriatelZivot2 <= 0) + { + Console.WriteLine($"Porazil si {nepriatelMeno} a vyhral si hru! Gratulujem!"); + } } - else + + + // bonusova aréna + Console.WriteLine("Gratulujem ze si vyhral hru! Ak chces pokracovat do bonusovej areny tak napis : Y; ak nie napis : N."); + Console.ReadLine(); + if (InvOpen2.ToString().ToUpper() == "Y") + Console.WriteLine("Pokračujes do bonusovej arény!"); { - Console.WriteLine($"Vyriesil si {score} z 3 prikladov spravne. Skus to znova nabuduce!"); + + Console.WriteLine("Vitaj v bonusovej arene!"); + Console.WriteLine("Tvoj nepriatel v bonusovej arene bude matematika!"); + Console.WriteLine("Tvojou ulohou je vyriesit 3 priklady spravne aby si vyhral bonusovu arenu!"); + int score = 0; + Console.WriteLine("Priklad 1: Kolko je 5 + 8 * 4 ?"); + int answer1 = int.Parse(Console.ReadLine()); + if (answer1 == 37) + { + score++; + Console.WriteLine("Spravne!"); + } + else + { + Console.WriteLine("Nespravne!"); + } + Console.WriteLine("Priklad 2: Kolko je (10 + 5) / 5 * 16 ?"); + int answer2 = int.Parse(Console.ReadLine()); + if (answer2 == 48) + { + score++; + Console.WriteLine("Spravne!"); + } + else + { + Console.WriteLine("Nespravne!"); + } + Console.WriteLine("Priklad 3: Kolko je 18 + 2 ?"); + int answer3 = int.Parse(Console.ReadLine()); + if (answer3 == 20) + { + score++; + Console.WriteLine("Spravne!"); + } + else + { + Console.WriteLine("Nespravne!"); + } + if (score == 3) + { + Console.WriteLine("Gratulujem! Vyriesil si vsetky priklady spravne a vyhral bonusovu arenu!"); + } + else + { + Console.WriteLine($"Vyriesil si {score} z 3 prikladov spravne. Skus to znova nabuduce!"); + } } } +} + + + diff --git a/Grafiti/Grafiti.csproj b/Grafiti/Grafiti.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/Grafiti/Grafiti.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Grafiti/Program.cs b/Grafiti/Program.cs new file mode 100644 index 00000000..6d317e80 --- /dev/null +++ b/Grafiti/Program.cs @@ -0,0 +1,954 @@ + +Console.BackgroundColor = ConsoleColor.Black; +Console.ForegroundColor = ConsoleColor.White; + +Console.WriteLine("Zadajte text: "); +string input = Console.ReadLine(); +string output = ""; +string[,] matrix = new string[100, 200]; +int offset = 0; + +foreach (char inputLetter in input) +{ + string outLetter = GetLetter(inputLetter.ToString()); + string[] lines = outLetter.Split(Environment.NewLine); + int letterWidth = 0; + + for (int i = 0; i < lines.Length; i++) + { + string character = lines[i]; + letterWidth = Math.Max(lines[i].Length, letterWidth); + + for (int j = 0; j < character.Length; j++) + { + matrix[i, j + offset] = character[j].ToString(); + } + } + offset = offset + letterWidth; +} + +for (int i = 0; i < matrix.GetLength(0); i++) +{ + for (int j = 0;j < matrix.GetLength(1); j++) + { + Console.Write(matrix[i, j]); + } + Console.WriteLine(); +} + + +string GetLetter(string input) +{ + switch (input) + { + case "A": + case "a": + return GetLetterA(); + case "B": + case "b": + return GetLetterB(); + case "C": + case "c": + return GetLetterC(); + case "D": + case "d": + return GetLetterD(); + case "E": + case "e": + return GetLetterE(); + case "F": + case "f": + return GetLetterF(); + case "G": + case "g": + return GetLetterG(); + case "H": + case "h": + return GetLetterH(); + case "I": + case "i": + return GetLetterI(); + case "J": + case "j": + return GetLetterJ(); + case "K": + case "k": + return GetLetterK(); + case "L": + case "l": + return GetLetterL(); + case "M": + case "m": + return GetLetterM(); + case "N": + case "n": + return GetLetterN(); + case "O": + case "o": + return GetLetterO(); + case "P": + case "p": + return GetLetterP(); + case "R": + case "r": + return GetLetterR(); + case "S": + case "s": + return GetLetterS(); + case "T": + case "t": + return GetLetterT(); + case "U": + case "u": + return GetLetterU(); + case "V": + case "v": + return GetLetterV(); + case "W": + case "w": + return GetLetterW(); + case "X": + case "x": + return GetLetterX(); + case "Y": + case "y": + return GetLetterY(); + case "Z": + case "z": + return GetLetterZ(); + + case "0": + return GetNumber0(); + case "1": + return GetNumber1(); + case "2": + return GetNumber2(); + case "3": + return GetNumber3(); + case "4": + return GetNumber4(); + case "5": + return GetNumber5(); + case "6": + return GetNumber6(); + case "7": + return GetNumber7(); + case "8": + return GetNumber8(); + case "9": + return GetNumber9(); + default: + return "Pismeno nie je podporovane."; + } +} + string GetLetterA() +{ + return @" + + AAA + A:::A + A:::::A + A:::::::A + A:::::::::A + A:::::A:::::A + A:::::A A:::::A + A:::::A A:::::A + A:::::A A:::::A + A:::::AAAAAAAAA:::::A + A:::::::::::::::::::::A + A:::::AAAAAAAAAAAAA:::::A + A:::::A A:::::A + A:::::A A:::::A + A:::::A A:::::A +AAAAAAA AAAAAAA + + "; +} +string GetLetterB() +{ + return @" + +BBBBBBBBBBBBBBBBB +B::::::::::::::::B +B::::::BBBBBB:::::B +BB:::::B B:::::B + B::::B B:::::B + B::::B B:::::B + B::::BBBBBB:::::B + B:::::::::::::BB + B::::BBBBBB:::::B + B::::B B:::::B + B::::B B:::::B + B::::B B:::::B +BB:::::BBBBBB::::::B +B:::::::::::::::::B +B::::::::::::::::B +BBBBBBBBBBBBBBBBB + +"; +} +string GetLetterC() +{ + return @" + + CCCCCCCCCCCCC + CCC::::::::::::C + CC:::::::::::::::C + C:::::CCCCCCCC::::C + C:::::C CCCCCC +C:::::C +C:::::C +C:::::C +C:::::C +C:::::C +C:::::C + C:::::C CCCCCC + C:::::CCCCCCCC::::C + CC:::::::::::::::C + CCC::::::::::::C + CCCCCCCCCCCCC + +"; +} +string GetLetterD() +{ + return @" + +DDDDDDDDDDDDD +D::::::::::::DDD +D:::::::::::::::DD +DDD:::::DDDDD:::::D + D:::::D D:::::D + D:::::D D:::::D + D:::::D D:::::D + D:::::D D:::::D + D:::::D D:::::D + D:::::D D:::::D + D:::::D D:::::D + D:::::D D:::::D +DDD:::::DDDDD:::::D +D:::::::::::::::DD +D::::::::::::DDD +DDDDDDDDDDDDD + + "; +} +string GetLetterE() +{ + return @" + +EEEEEEEEEEEEEEEEEEEEEE +E::::::::::::::::::::E +E::::::::::::::::::::E +EE::::::EEEEEEEEE::::E + E:::::E EEEEEE + E:::::E + E::::::EEEEEEEEEE + E:::::::::::::::E + E:::::::::::::::E + E::::::EEEEEEEEEE + E:::::E + E:::::E EEEEEE +EE::::::EEEEEEEE:::::E +E::::::::::::::::::::E +E::::::::::::::::::::E +EEEEEEEEEEEEEEEEEEEEEE + +"; +} +string GetLetterF() +{ + return @" + +FFFFFFFFFFFFFFFFFFFFFF +F::::::::::::::::::::F +F::::::::::::::::::::F +FF::::::FFFFFFFFF::::F + F:::::F FFFFFF + F:::::F + F::::::FFFFFFFFFF + F:::::::::::::::F + F:::::::::::::::F + F::::::FFFFFFFFFF + F:::::F + F:::::F +FF:::::::FF +F::::::::FF +F::::::::FF +FFFFFFFFFFF + +"; +} +string GetLetterG() +{ + return @" + + GGGGGGGGGGGGG + GGG::::::::::::G + GG:::::::::::::::G + G:::::GGGGGGGG::::G + G:::::G GGGGGG +G:::::G +G:::::G +G:::::G GGGGGGGGGG +G:::::G G::::::::G +G:::::G GGGGG::::G +G:::::G G::::G + G:::::G G::::G + G:::::GGGGGGGG::::G + GG:::::::::::::::G + GGG::::::GGG:::G + GGGGGG GGGG + + "; +} +string GetLetterH() +{ + return @" + +HHHHHHHHH HHHHHHHHH +H:::::::H H:::::::H +H:::::::H H:::::::H +HH::::::H H::::::HH + H:::::H H:::::H + H:::::H H:::::H + H::::::HHHHH::::::H + H:::::::::::::::::H + H:::::::::::::::::H + H::::::HHHHH::::::H + H:::::H H:::::H + H:::::H H:::::H +HH::::::H H::::::HH +H:::::::H H:::::::H +H:::::::H H:::::::H +HHHHHHHHH HHHHHHHHH + + "; +} +string GetLetterI() +{ + return @" + +IIIIIIIIII +I::::::::I +I::::::::I +II::::::II + I::::I + I::::I + I::::I + I::::I + I::::I + I::::I + I::::I + I::::I +II::::::II +I::::::::I +I::::::::I +IIIIIIIIII + +"; +} +string GetLetterJ() +{ + return @" + + JJJJJJJJJJJ + J:::::::::J + J:::::::::J + JJ:::::::JJ + J:::::J + J:::::J + J:::::J + J:::::j + J:::::J +JJJJJJJ J:::::J +J:::::J J:::::J +J::::::J J::::::J +J:::::::JJJ:::::::J + JJ:::::::::::::JJ + JJ:::::::::JJ + JJJJJJJJJ + + "; +} +string GetLetterK() +{ + return @" + +KKKKKKKKK KKKKKKK +K:::::::K K:::::K +K:::::::K K:::::K +K:::::::K K::::::K +KK::::::K K:::::KKK + K:::::K K:::::K + K::::::K:::::K + K:::::::::::K + K:::::::::::K + K::::::K:::::K + K:::::K K:::::K +KK::::::K K:::::KKK +K:::::::K K::::::K +K:::::::K K:::::K +K:::::::K K:::::K +KKKKKKKKK KKKKKKK + + "; +} +string GetLetterL() +{ + return @" + +LLLLLLLLLLL +L:::::::::L +L:::::::::L +LL:::::::LL + L:::::L + L:::::L + L:::::L + L:::::L + L:::::L + L:::::L + L:::::L + L:::::L LLLLLL +LL:::::::LLLLLLLLL:::::L +L::::::::::::::::::::::L +L::::::::::::::::::::::L +LLLLLLLLLLLLLLLLLLLLLLLL + + "; +} +string GetLetterM() +{ + return @" + +MMMMMMMM MMMMMMMM +M:::::::M M:::::::M +M::::::::M M::::::::M +M:::::::::M M:::::::::M +M::::::::::M M::::::::::M +M:::::::::::M M:::::::::::M +M:::::::M::::M M::::M:::::::M +M::::::M M::::M M::::M M::::::M +M::::::M M::::M::::M M::::::M +M::::::M M:::::::M M::::::M +M::::::M M:::::M M::::::M +M::::::M MMMMM M::::::M +M::::::M M::::::M +M::::::M M::::::M +M::::::M M::::::M +MMMMMMMM MMMMMMMM + + "; +} +string GetLetterN() +{ + return @" + +NNNNNNNN NNNNNNNN +N:::::::N N::::::N +N::::::::N N::::::N +N:::::::::N N::::::N +N::::::::::N N::::::N +N:::::::::::N N::::::N +N:::::::N::::N N::::::N +N::::::N N::::N N::::::N +N::::::N N::::N:::::::N +N::::::N N:::::::::::N +N::::::N N::::::::::N +N::::::N N:::::::::N +N::::::N N::::::::N +N::::::N N:::::::N +N::::::N N::::::N +NNNNNNNN NNNNNNN + +"; +} +string GetLetterO() +{ + return @" + + OOOOOOOOO + OO:::::::::OO + OO:::::::::::::OO +O:::::::OOO:::::::O +O::::::O O::::::O +O:::::O O:::::O +O:::::O O:::::O +O:::::O O:::::O +O:::::O O:::::O +O:::::O O:::::O +O:::::O O:::::O +O::::::O O::::::O +O:::::::OOO:::::::O + OO:::::::::::::OO + OO:::::::::OO + OOOOOOOOO + + "; +} +string GetLetterP() +{ + return @" + +PPPPPPPPPPPPPPPPP +P::::::::::::::::P +P::::::PPPPPP:::::P +PP:::::P P:::::P + P::::P P:::::P + P::::P P:::::P + P::::PPPPPP:::::P + P:::::::::::::PP + P::::PPPPPPPPP + P::::P + P::::P + P::::P +PP::::::PP +P::::::::P +P::::::::P +PPPPPPPPPP + +"; +} +string GetLetterR() +{ + return @" + +RRRRRRRRRRRRRRRRR +R::::::::::::::::R +R::::::RRRRRR:::::R +RR:::::R R:::::R + R::::R R:::::R + R::::R R:::::R + R::::RRRRRR:::::R + R:::::::::::::RR + R::::RRRRRR:::::R + R::::R R:::::R + R::::R R:::::R + R::::R R:::::R +RR:::::R R:::::R +R::::::R R:::::R +R::::::R R:::::R +RRRRRRRR RRRRRRR + + "; +} +string GetLetterS() +{ + return @" + + SSSSSSSSSSSSSSS + SS:::::::::::::::S +S:::::SSSSSS::::::S +S:::::S SSSSSSS +S:::::S +S:::::S + S::::SSSS + SS::::::SSSSS + SSS::::::::SS + SSSSSS::::S + S:::::S + S:::::S +SSSSSSS S:::::S +S::::::SSSSSS:::::S +S:::::::::::::::SS + SSSSSSSSSSSSSSS + +"; +} +string GetLetterT() +{ + return @" + +TTTTTTTTTTTTTTTTTTTTTTT +T:::::::::::::::::::::T +T:::::::::::::::::::::T +T:::::TT:::::::TT:::::T +TTTTTT T:::::T TTTTTT + T:::::T + T:::::T + T:::::T + T:::::T + T:::::T + T:::::T + T:::::T + TT:::::::TT + T:::::::::T + T:::::::::T + TTTTTTTTTTT + + "; +} +string GetLetterU() +{ + return @" + +UUUUUUUU UUUUUUUU +U::::::U U::::::U +U::::::U U::::::U +UU:::::U U:::::UU + U:::::U U:::::U + U:::::D D:::::U + U:::::D D:::::U + U:::::D D:::::U + U:::::D D:::::U + U:::::D D:::::U + U:::::D D:::::U + U::::::U U::::::U + U:::::::UUU:::::::U + UU:::::::::::::UU + UU:::::::::UU + UUUUUUUUU + + "; +} +string GetLetterV() +{ + return @" + +VVVVVVVV VVVVVVVV +V::::::V V::::::V +V::::::V V::::::V +V::::::V V::::::V + V:::::V V:::::V + V:::::V V:::::V + V:::::V V:::::V + V:::::V V:::::V + V:::::V V:::::V + V:::::V V:::::V + V:::::V:::::V + V:::::::::V + V:::::::V + V:::::V + V:::V + VVV + +"; +} +string GetLetterW() +{ + return @" + +WWWWWWWW WWWWWWWW +W::::::W W::::::W +W::::::W W::::::W +W::::::W W::::::W + W:::::W WWWWW W:::::W + W:::::W W:::::W W:::::W + W:::::W W:::::::W W:::::W + W:::::W W:::::::::W W:::::W + W:::::W W:::::W:::::W W:::::W + W:::::W W:::::W W:::::W W:::::W + W:::::W:::::W W:::::W:::::W + W:::::::::W W:::::::::W + W:::::::W W:::::::W + W:::::W W:::::W + W:::W W:::W + WWW WWW + +"; +} +string GetLetterX() +{ + return @" + +XXXXXXX XXXXXXX +X:::::X X:::::X +X:::::X X:::::X +X::::::X X::::::X +XXX:::::X X:::::XXX + X:::::X X:::::X + X:::::X:::::X + X:::::::::X + X:::::::::X + X:::::X:::::X + X:::::X X:::::X +XXX:::::X X:::::XXX +X::::::X X::::::X +X:::::X X:::::X +X:::::X X:::::X +XXXXXXX XXXXXXX + + "; +} +string GetLetterY() +{ + return @" + +YYYYYYY YYYYYYY +Y:::::Y Y:::::Y +Y:::::Y Y:::::Y +Y::::::Y Y::::::Y +YYY:::::Y Y:::::YYY + Y:::::Y Y:::::Y + Y:::::Y:::::Y + Y:::::::::Y + Y:::::::Y + Y:::::Y + Y:::::Y + Y:::::Y + Y:::::Y + YYYY:::::YYYY + Y:::::::::::Y + YYYYYYYYYYYYY + +"; +} +string GetLetterZ() +{ + return @" + +ZZZZZZZZZZZZZZZZZZZ +Z:::::::::::::::::Z +Z:::::::::::::::::Z +Z:::ZZZZZZZZ:::::Z +ZZZZZ Z:::::Z + Z:::::Z + Z:::::Z + Z:::::Z + Z:::::Z + Z:::::Z + Z:::::Z +ZZZ:::::Z ZZZZZ +Z::::::ZZZZZZZZ:::Z +Z:::::::::::::::::Z +Z:::::::::::::::::Z +ZZZZZZZZZZZZZZZZZZZ + +"; +} + + +string GetNumber0() +{ + return @" + + 000000000 + 00:::::::::00 + 00:::::::::::::00 +0:::::::000:::::::0 +0::::::0 0::::::0 +0:::::0 0:::::0 +0:::::0 0:::::0 +0:::::0 000 0:::::0 +0:::::0 000 0:::::0 +0:::::0 0:::::0 +0:::::0 0:::::0 +0::::::0 0::::::0 +0:::::::000:::::::0 + 00:::::::::::::00 + 00:::::::::00 + 000000000 + +"; +} +string GetNumber1() +{ + return @" + + 1111111 + 1::::::1 +1:::::::1 +111:::::1 + 1::::1 + 1::::1 + 1::::1 + 1::::l + 1::::l + 1::::l + 1::::l + 1::::l +111::::::111 +1::::::::::1 +1::::::::::1 +111111111111 + +"; +} +string GetNumber2() +{ + return @" + + 222222222222222 +2:::::::::::::::22 +2::::::222222:::::2 +2222222 2:::::2 + 2:::::2 + 2:::::2 + 2222::::2 + 22222::::::22 + 22::::::::222 + 2:::::22222 +2:::::2 +2:::::2 +2:::::2 222222 +2::::::2222222:::::2 +2::::::::::::::::::2 +22222222222222222222 + +"; +} +string GetNumber3() +{ + return @" + + 333333333333333 +3:::::::::::::::33 +3::::::33333::::::3 +3333333 3:::::3 + 3:::::3 + 3:::::3 + 33333333:::::3 + 3:::::::::::3 + 33333333:::::3 + 3:::::3 + 3:::::3 + 3:::::3 +3333333 3:::::3 +3::::::33333::::::3 +3:::::::::::::::33 + 333333333333333 + +"; +} +string GetNumber4() +{ + return @" + + 444444444 + 4::::::::4 + 4:::::::::4 + 4::::44::::4 + 4::::4 4::::4 + 4::::4 4::::4 + 4::::4 4::::4 +4::::444444::::444 +4::::::::::::::::4 +4444444444:::::444 + 4::::4 + 4::::4 + 4::::4 + 44::::::44 + 4::::::::4 + 4444444444 + +"; +} +string GetNumber5() +{ + return @" + +555555555555555555 +5::::::::::::::::5 +5::::::::::::::::5 +5:::::555555555555 +5:::::5 +5:::::5 +5:::::5555555555 +5:::::::::::::::5 +555555555555:::::5 + 5:::::5 + 5:::::5 +5555555 5:::::5 +5::::::55555::::::5 + 55:::::::::::::55 + 55:::::::::55 + 555555555 + +"; +} +string GetNumber6() +{ + return @" + + 66666666 + 6::::::6 + 6::::::6 + 6::::::6 + 6::::::6 + 6::::::6 + 6::::::6 + 6::::::::66666 +6::::::::::::::66 +6::::::66666:::::6 +6:::::6 6:::::6 +6:::::6 6:::::6 +6::::::66666::::::6 + 66:::::::::::::66 + 66:::::::::66 + 666666666 + +"; +} +string GetNumber7() +{ + return @" + +77777777777777777777 +7::::::::::::::::::7 +7::::::::::::::::::7 +777777777777:::::::7 + 7::::::7 + 7::::::7 + 7::::::7 + 7::::::7 + 7::::::7 + 7::::::7 + 7::::::7 + 7::::::7 + 7::::::7 + 7::::::7 + 7::::::7 +77777777 + +"; +} +string GetNumber8() +{ + return @" + + 888888888 + 88:::::::::88 + 88:::::::::::::88 +8::::::88888::::::8 +8:::::8 8:::::8 +8:::::8 8:::::8 + 8:::::88888:::::8 + 8:::::::::::::8 + 8:::::88888:::::8 +8:::::8 8:::::8 +8:::::8 8:::::8 +8:::::8 8:::::8 +8::::::88888::::::8 + 88:::::::::::::88 + 88:::::::::88 + 888888888 + +"; +} +string GetNumber9() +{ + return @" + + 999999999 + 99:::::::::99 + 99:::::::::::::99 +9::::::99999::::::9 +9:::::9 9:::::9 +9:::::9 9:::::9 + 9:::::99999::::::9 + 99::::::::::::::9 + 99999::::::::9 + 9::::::9 + 9::::::9 + 9::::::9 + 9::::::9 + 9::::::9 + 9::::::9 + 99999999 + +"; +} + + + + diff --git a/Grafitti/Grafitti.csproj b/Grafitti/Grafitti.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/Grafitti/Grafitti.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Grafitti/Program.cs b/Grafitti/Program.cs new file mode 100644 index 00000000..3751555c --- /dev/null +++ b/Grafitti/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); From 233fc45e0e6010bb7963755083da3a97bb63f705 Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Wed, 29 Oct 2025 07:32:43 +0100 Subject: [PATCH 19/21] Urobil som zoznam filmov. --- AppsLab.CSharp.Exercises.sln | 15 +++ Moje filmy/Moje filmy.csproj | 11 +++ Moje filmy/Program.cs | 185 +++++++++++++++++++++++++++++++++++ 3 files changed, 211 insertions(+) create mode 100644 Moje filmy/Moje filmy.csproj create mode 100644 Moje filmy/Program.cs diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index 290abaff..f90b1496 100644 --- a/AppsLab.CSharp.Exercises.sln +++ b/AppsLab.CSharp.Exercises.sln @@ -101,6 +101,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp6", "ConsoleApp6\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grafiti", "Grafiti\Grafiti.csproj", "{67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moje filmy", "Moje filmy\Moje filmy.csproj", "{3951A6B3-7ACE-446D-987C-812BB1AA3E37}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -675,6 +677,18 @@ Global {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}.Release|x64.Build.0 = Release|Any CPU {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}.Release|x86.ActiveCfg = Release|Any CPU {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A}.Release|x86.Build.0 = Release|Any CPU + {3951A6B3-7ACE-446D-987C-812BB1AA3E37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3951A6B3-7ACE-446D-987C-812BB1AA3E37}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3951A6B3-7ACE-446D-987C-812BB1AA3E37}.Debug|x64.ActiveCfg = Debug|Any CPU + {3951A6B3-7ACE-446D-987C-812BB1AA3E37}.Debug|x64.Build.0 = Debug|Any CPU + {3951A6B3-7ACE-446D-987C-812BB1AA3E37}.Debug|x86.ActiveCfg = Debug|Any CPU + {3951A6B3-7ACE-446D-987C-812BB1AA3E37}.Debug|x86.Build.0 = Debug|Any CPU + {3951A6B3-7ACE-446D-987C-812BB1AA3E37}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3951A6B3-7ACE-446D-987C-812BB1AA3E37}.Release|Any CPU.Build.0 = Release|Any CPU + {3951A6B3-7ACE-446D-987C-812BB1AA3E37}.Release|x64.ActiveCfg = Release|Any CPU + {3951A6B3-7ACE-446D-987C-812BB1AA3E37}.Release|x64.Build.0 = Release|Any CPU + {3951A6B3-7ACE-446D-987C-812BB1AA3E37}.Release|x86.ActiveCfg = Release|Any CPU + {3951A6B3-7ACE-446D-987C-812BB1AA3E37}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -724,6 +738,7 @@ Global {38FFE1DF-4B49-40C1-9908-51860BCF2D3E} = {56555FB0-B513-49EF-9002-A5AF135EA090} {83C963FD-DC23-46E8-9545-F56197164810} = {56555FB0-B513-49EF-9002-A5AF135EA090} {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A} = {56555FB0-B513-49EF-9002-A5AF135EA090} + {3951A6B3-7ACE-446D-987C-812BB1AA3E37} = {56555FB0-B513-49EF-9002-A5AF135EA090} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0463079C-E8B4-4F31-9B34-80769936C76B} diff --git a/Moje filmy/Moje filmy.csproj b/Moje filmy/Moje filmy.csproj new file mode 100644 index 00000000..b9c32044 --- /dev/null +++ b/Moje filmy/Moje filmy.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + Moje_filmy + enable + enable + + + diff --git a/Moje filmy/Program.cs b/Moje filmy/Program.cs new file mode 100644 index 00000000..085dd441 --- /dev/null +++ b/Moje filmy/Program.cs @@ -0,0 +1,185 @@ + +// uvod + +Console.WriteLine("Vitaj v mojom svete filmov! "); +Console.WriteLine("Mozes si vybrat film ktory chces pozerat. "); +Console.WriteLine("Vsetky ktore tu vidi su moje oblubene. "); +// + +// ukazka co to dokaze + +Console.WriteLine("Tu mas moznosti, ktore mozes robit v mojej verzii 'kukaj to'!"); +Console.WriteLine("1 = Zoznam filmov!"); +Console.WriteLine("2 = Pridat film!"); +Console.WriteLine("3 = Vyhladat film!"); +Console.WriteLine("4 = Zmazat film!"); +Console.WriteLine("5 = Ukoncit program!"); +Console.WriteLine("Podla toho co chces urobit tak zadaj cislo od 1 - 5: "); +string program = Console.ReadLine(); +string vysledok = ""; +// + + +//opakovanie moznosti +bool koniec = false; +while (!koniec) + + +{ + // vypisanie moznosti + switch (program) + { + case "1": + ZobrazZoznamFilmov(ZoznamFilmov); + break; + + case "2": + Console.WriteLine("Zadaj nazov filmu na pridanie: "); + string novy = Console.ReadLine(); + ZoznamFilmov.Add(novy); + Console.WriteLine("Film bol pridany!"); + break; + + case "3": + string hladany = ZiskanieFilmu(); + bool najdeny = VyhladatFilm(ZoznamFilmov, hladany); + ZobrazitVysledok(hladany, najdeny); + break; + + case "4": + Console.WriteLine("Zadaj nazov filmu na vymazanie: "); + string mazany = Console.ReadLine(); + bool vymazany = VymazFilm(ZoznamFilmov, mazany); + ZobrazVysledokVymazania(mazany, vymazany); + break; + + case "5": + UkoncenieProgramu(); + break; + + } + + + + + // zoznam filmov + List ZoznamFilmov = new List(); + if (program == "1") + { + Console.WriteLine("Tu je moj zoznam! "); + Console.WriteLine("(1) = Rychlo a zbesilo! "); + Console.WriteLine("(2) = Thor! "); + Console.WriteLine("(3) = Hulk! "); + Console.WriteLine("(4) = Capiatn America! "); + Console.WriteLine("(5) = Spider man! "); + Console.WriteLine("(6) = Hobit! "); + Console.WriteLine("(7) = Zaklinac! "); + Console.WriteLine("(8) = Pan prstenov! "); + Console.WriteLine("(9) = Ocelova pest! "); + Console.WriteLine("(10) = Transformers! "); + } + // + + + // pridanie filmov do zoznmau + Console.WriteLine("Zadaj nazov filmu na pridanie: "); + string novyFilm = Console.ReadLine(); + PridatFilm.Add(novyFilm); + ZoznamFilmov.AddRange(PridatFilm); + PridatFilm.Clear(); + Console.WriteLine($"Film '{novyFilm}' bol pridany do zoznamu!"); + // + + + // hladanie filmu + string ZiskanieFilmu() + { + Console.WriteLine(" Ziskavanie filmu! "); + Console.WriteLine("Zadaj nazov filmu ktory chces pozerat!: "); + return Console.ReadLine(); + } + + bool VyhladatFilm(List filmy, string HladanyFilm) + { + return filmy.Exists(f => f.Equals(HladanyFilm, StringComparison.OrdinalIgnoreCase)); + } + + void ZobrazitVysledok(string HladanyFilm, bool najdeny) + { + if (najdeny) + { + Console.WriteLine($"Film {HladanyFilm} sa nasiel v zozname! "); + } + else + { + Console.WriteLine($"Film {HladanyFilm} sa nenasiel v zozname! "); + } + } + // + + + // vymazanie filmov + + void ZobrazZoznamFilmov(List filmy) + { + Console.WriteLine("Aktualny zoznam filmov! "); + foreach (string film in filmy) + { + Console.WriteLine($"{film}"); + } + Console.WriteLine(); + } + bool VymazFilm(List filmy, string FilmNaVymazanie) + { + string film = filmy.Find(f => f.Equals(FilmNaVymazanie, StringComparison.OrdinalIgnoreCase)); + if (film != null) + { + filmy.Remove(film); + return true; + } + else + { + return false; + } + } + void ZobrazVysledokVymazania(string FilmNaVymazanie, bool vymazany) + { + if (vymazany) + { + Console.WriteLine($"Film {FilmNaVymazanie} bol vymazany zo zoznamu! "); + } + else + { + Console.WriteLine($"Film {FilmNaVymazanie} sa nepodarilo vymazat! "); + } + } + // + + + //ukoncenie programu + void UkoncenieProgramu() + { + Console.WriteLine("Ukoncenie programu! "); + Console.WriteLine("Naozaj chces ukoncit program? (A/N): "); + string odpoved = Console.ReadLine(); + } + void UkoncienieProgramu() + { + Console.WriteLine("Naozaj chces ukoncit program? (A/N): "); + string odpoved = Console.ReadLine(); + + if (odpoved.Equals("A", StringComparison.OrdinalIgnoreCase)) + { + Console.WriteLine("Program sa ukoncuje... Dakujem za pouzitie!"); + Environment.Exit(0); + } + else + { + Console.WriteLine("Ukoncenie programu bolo zrusene. Pokracujes dalej!"); + } + } + void ZrusitUkoncenie() + { + Console.WriteLine("Ukonacenie programu bolo zrusene. pokracijes dalej! "); + } +} \ No newline at end of file From 7a3421d588bfada65f48dd8622b661eb4e0a02f3 Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Tue, 4 Nov 2025 16:43:02 +0100 Subject: [PATCH 20/21] urobil som novu hru pomocou OOP. --- AppsLab.CSharp.Exercises.sln | 43 ++++++++++++++++++ Hra_OOP/Boss.cs | 38 ++++++++++++++++ Hra_OOP/Character.cs | 31 +++++++++++++ Hra_OOP/Hra_OOP.csproj | 10 ++++ Hra_OOP/MojCharakter.cs | 40 ++++++++++++++++ Hra_OOP/Monster.cs | 41 +++++++++++++++++ Hra_OOP/Player.cs | 29 ++++++++++++ Hra_OOP/Prisera.cs | 45 ++++++++++++++++++ Hra_OOP/Program.cs | 83 ++++++++++++++++++++++++++++++++++ Hra_OOP/character1.cs | 21 +++++++++ Hra_OOP/monster1.cs | 39 ++++++++++++++++ OOP_2/Animal.cs | 24 ++++++++++ OOP_2/Masozravec.cs | 12 +++++ OOP_2/OOP_2..csproj | 11 +++++ OOP_2/Program.cs | 18 ++++++++ OOP_2/bylinozravec.cs | 12 +++++ OOP_3/OOP_3..csproj | 11 +++++ OOP_3/Program.cs | 13 ++++++ OOP_3/Student.cs | 34 ++++++++++++++ OOP_3/student1.cs | 11 +++++ src/AppsLab-020-OOP/Monster.cs | 23 ++++++++++ src/AppsLab-020-OOP/Player.cs | 36 +++++++++++++++ src/AppsLab-020-OOP/Program.cs | 13 +++++- 23 files changed, 636 insertions(+), 2 deletions(-) create mode 100644 Hra_OOP/Boss.cs create mode 100644 Hra_OOP/Character.cs create mode 100644 Hra_OOP/Hra_OOP.csproj create mode 100644 Hra_OOP/MojCharakter.cs create mode 100644 Hra_OOP/Monster.cs create mode 100644 Hra_OOP/Player.cs create mode 100644 Hra_OOP/Prisera.cs create mode 100644 Hra_OOP/Program.cs create mode 100644 Hra_OOP/character1.cs create mode 100644 Hra_OOP/monster1.cs create mode 100644 OOP_2/Animal.cs create mode 100644 OOP_2/Masozravec.cs create mode 100644 OOP_2/OOP_2..csproj create mode 100644 OOP_2/Program.cs create mode 100644 OOP_2/bylinozravec.cs create mode 100644 OOP_3/OOP_3..csproj create mode 100644 OOP_3/Program.cs create mode 100644 OOP_3/Student.cs create mode 100644 OOP_3/student1.cs create mode 100644 src/AppsLab-020-OOP/Monster.cs create mode 100644 src/AppsLab-020-OOP/Player.cs diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index f90b1496..415c5dd8 100644 --- a/AppsLab.CSharp.Exercises.sln +++ b/AppsLab.CSharp.Exercises.sln @@ -103,6 +103,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grafiti", "Grafiti\Grafiti. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moje filmy", "Moje filmy\Moje filmy.csproj", "{3951A6B3-7ACE-446D-987C-812BB1AA3E37}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OOP_2.", "OOP_2\OOP_2..csproj", "{1502E2B1-4AF8-4CFA-A7E2-39DFA36198F4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OOP_3.", "OOP_3\OOP_3..csproj", "{5608DCE5-07A1-4645-8E35-EC4CCFE93642}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hra_OOP", "Hra_OOP\Hra_OOP.csproj", "{0D7B0722-2D9C-4381-B87B-4677E0418A94}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -689,6 +695,42 @@ Global {3951A6B3-7ACE-446D-987C-812BB1AA3E37}.Release|x64.Build.0 = Release|Any CPU {3951A6B3-7ACE-446D-987C-812BB1AA3E37}.Release|x86.ActiveCfg = Release|Any CPU {3951A6B3-7ACE-446D-987C-812BB1AA3E37}.Release|x86.Build.0 = Release|Any CPU + {1502E2B1-4AF8-4CFA-A7E2-39DFA36198F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1502E2B1-4AF8-4CFA-A7E2-39DFA36198F4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1502E2B1-4AF8-4CFA-A7E2-39DFA36198F4}.Debug|x64.ActiveCfg = Debug|Any CPU + {1502E2B1-4AF8-4CFA-A7E2-39DFA36198F4}.Debug|x64.Build.0 = Debug|Any CPU + {1502E2B1-4AF8-4CFA-A7E2-39DFA36198F4}.Debug|x86.ActiveCfg = Debug|Any CPU + {1502E2B1-4AF8-4CFA-A7E2-39DFA36198F4}.Debug|x86.Build.0 = Debug|Any CPU + {1502E2B1-4AF8-4CFA-A7E2-39DFA36198F4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1502E2B1-4AF8-4CFA-A7E2-39DFA36198F4}.Release|Any CPU.Build.0 = Release|Any CPU + {1502E2B1-4AF8-4CFA-A7E2-39DFA36198F4}.Release|x64.ActiveCfg = Release|Any CPU + {1502E2B1-4AF8-4CFA-A7E2-39DFA36198F4}.Release|x64.Build.0 = Release|Any CPU + {1502E2B1-4AF8-4CFA-A7E2-39DFA36198F4}.Release|x86.ActiveCfg = Release|Any CPU + {1502E2B1-4AF8-4CFA-A7E2-39DFA36198F4}.Release|x86.Build.0 = Release|Any CPU + {5608DCE5-07A1-4645-8E35-EC4CCFE93642}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5608DCE5-07A1-4645-8E35-EC4CCFE93642}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5608DCE5-07A1-4645-8E35-EC4CCFE93642}.Debug|x64.ActiveCfg = Debug|Any CPU + {5608DCE5-07A1-4645-8E35-EC4CCFE93642}.Debug|x64.Build.0 = Debug|Any CPU + {5608DCE5-07A1-4645-8E35-EC4CCFE93642}.Debug|x86.ActiveCfg = Debug|Any CPU + {5608DCE5-07A1-4645-8E35-EC4CCFE93642}.Debug|x86.Build.0 = Debug|Any CPU + {5608DCE5-07A1-4645-8E35-EC4CCFE93642}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5608DCE5-07A1-4645-8E35-EC4CCFE93642}.Release|Any CPU.Build.0 = Release|Any CPU + {5608DCE5-07A1-4645-8E35-EC4CCFE93642}.Release|x64.ActiveCfg = Release|Any CPU + {5608DCE5-07A1-4645-8E35-EC4CCFE93642}.Release|x64.Build.0 = Release|Any CPU + {5608DCE5-07A1-4645-8E35-EC4CCFE93642}.Release|x86.ActiveCfg = Release|Any CPU + {5608DCE5-07A1-4645-8E35-EC4CCFE93642}.Release|x86.Build.0 = Release|Any CPU + {0D7B0722-2D9C-4381-B87B-4677E0418A94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0D7B0722-2D9C-4381-B87B-4677E0418A94}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0D7B0722-2D9C-4381-B87B-4677E0418A94}.Debug|x64.ActiveCfg = Debug|Any CPU + {0D7B0722-2D9C-4381-B87B-4677E0418A94}.Debug|x64.Build.0 = Debug|Any CPU + {0D7B0722-2D9C-4381-B87B-4677E0418A94}.Debug|x86.ActiveCfg = Debug|Any CPU + {0D7B0722-2D9C-4381-B87B-4677E0418A94}.Debug|x86.Build.0 = Debug|Any CPU + {0D7B0722-2D9C-4381-B87B-4677E0418A94}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0D7B0722-2D9C-4381-B87B-4677E0418A94}.Release|Any CPU.Build.0 = Release|Any CPU + {0D7B0722-2D9C-4381-B87B-4677E0418A94}.Release|x64.ActiveCfg = Release|Any CPU + {0D7B0722-2D9C-4381-B87B-4677E0418A94}.Release|x64.Build.0 = Release|Any CPU + {0D7B0722-2D9C-4381-B87B-4677E0418A94}.Release|x86.ActiveCfg = Release|Any CPU + {0D7B0722-2D9C-4381-B87B-4677E0418A94}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -739,6 +781,7 @@ Global {83C963FD-DC23-46E8-9545-F56197164810} = {56555FB0-B513-49EF-9002-A5AF135EA090} {67C2C93F-DD0D-4FD6-9A3F-4DCE97F7C26A} = {56555FB0-B513-49EF-9002-A5AF135EA090} {3951A6B3-7ACE-446D-987C-812BB1AA3E37} = {56555FB0-B513-49EF-9002-A5AF135EA090} + {0D7B0722-2D9C-4381-B87B-4677E0418A94} = {56555FB0-B513-49EF-9002-A5AF135EA090} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0463079C-E8B4-4F31-9B34-80769936C76B} diff --git a/Hra_OOP/Boss.cs b/Hra_OOP/Boss.cs new file mode 100644 index 00000000..5789311a --- /dev/null +++ b/Hra_OOP/Boss.cs @@ -0,0 +1,38 @@ + +namespace Hra_OOP +{ + internal class Boss + { + private const int bossHealth = 800; + private const int minHealth2 = 0; + + private int currentHp2 = bossHealth; + private int bossDamage = 200; + private object name2; + Boss nepriatel = new Boss(); + + + public bool DealDamage(MojCharacter opponent) + { + opponent.TakeDamage(bossDamage); + return true; + } + + public void TakeDamage(int bossDamage) + { + currentHp2 -= bossDamage; + if (currentHp2 < minHealth2) currentHp2 = minHealth2; + } + + public int GetCurrentHp() + { + return currentHp2; + } + + public override bool Equals(object? obj) + { + return obj is Boss boss && + name2 == boss.name2; + } + } +} diff --git a/Hra_OOP/Character.cs b/Hra_OOP/Character.cs new file mode 100644 index 00000000..b494be77 --- /dev/null +++ b/Hra_OOP/Character.cs @@ -0,0 +1,31 @@ + +namespace Hra_OOP +{ + public class Character + { + internal void DealDamage(Monster enemy) + { + throw new NotImplementedException(); + } + + internal object GetName() + { + throw new NotImplementedException(); + } + + internal bool IsAlive() + { + throw new NotImplementedException(); + } + + internal void TakeDamage(int monsterDamage) + { + throw new NotImplementedException(); + } + + public static implicit operator Character(MojCharacter v) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Hra_OOP/Hra_OOP.csproj b/Hra_OOP/Hra_OOP.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/Hra_OOP/Hra_OOP.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Hra_OOP/MojCharakter.cs b/Hra_OOP/MojCharakter.cs new file mode 100644 index 00000000..3249fe5a --- /dev/null +++ b/Hra_OOP/MojCharakter.cs @@ -0,0 +1,40 @@ + + +using Hra_OOP; + +public class MojCharacter + +{ + private const int characterHealth = 500; + private const int minHealth = 0; + + private int currentHp = characterHealth; + private int characterDamage = 100; + private object name; + MojCharacter hrac = new MojCharacter(); + + + public bool DealDamage(monster opponent) + { + opponent.TakeDamage(characterDamage); + return true; + } + + + public void TakeDamage(int characterDamage) + { + currentHp -= characterDamage; + if (currentHp < minHealth) currentHp = minHealth; + } + + public int GetCurrentHp() + { + return currentHp; + } + + public override bool Equals(object? obj) + { + return obj is MojCharacter character && + name == character.name; + } +} diff --git a/Hra_OOP/Monster.cs b/Hra_OOP/Monster.cs new file mode 100644 index 00000000..f9bc80e7 --- /dev/null +++ b/Hra_OOP/Monster.cs @@ -0,0 +1,41 @@ + +namespace Hra_OOP +{ + public class Monster + { + internal static void DealDamage(Player name) + { + throw new NotImplementedException(); + } + + internal void DealDamage(Character hero) + { + throw new NotImplementedException(); + } + + internal object GetName() + { + throw new NotImplementedException(); + } + + internal bool IsAlive() + { + throw new NotImplementedException(); + } + + internal void SetName(object monsterName) + { + throw new NotImplementedException(); + } + + internal void TakeDamage(int characterDamage) + { + throw new NotImplementedException(); + } + + public static implicit operator Monster(monster v) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Hra_OOP/Player.cs b/Hra_OOP/Player.cs new file mode 100644 index 00000000..b83bee9b --- /dev/null +++ b/Hra_OOP/Player.cs @@ -0,0 +1,29 @@ + +using Hra_OOP; + +internal class Player +{ + public Player() + { + } + + internal void DealDamage(Monster monster) + { + throw new NotImplementedException(); + } + + internal void DealDamage(monster name1) + { + throw new NotImplementedException(); + } + + internal void SetName(string? characterName) + { + throw new NotImplementedException(); + } + + internal void SetName(object playerName) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/Hra_OOP/Prisera.cs b/Hra_OOP/Prisera.cs new file mode 100644 index 00000000..2751d619 --- /dev/null +++ b/Hra_OOP/Prisera.cs @@ -0,0 +1,45 @@ + + + +namespace Hra_OOP +{ + public class Prisera + { + private const int maxHp = 400; + private const int minHp = 0; + + private string name; + private int currentHp = maxHp; + private int monsterDamage = 50; + private List monster = new List(); + + public object name1 { get; private set; } + public object monsterName { get; private set; } + + public bool DealDamage(character opponent) + { + opponent.TakeDamage(monsterDamage); + return true; + } + + public void SetName(string? playerName) + { + name1 = monsterName; + } + + public void TakeDamage(int playerDamage) + { + int currnetHp = playerDamage; + } + + public int GetCurrentHp() + { + return currentHp; + } + + public string GetName() + { + return name; + } + } +} diff --git a/Hra_OOP/Program.cs b/Hra_OOP/Program.cs new file mode 100644 index 00000000..b689a288 --- /dev/null +++ b/Hra_OOP/Program.cs @@ -0,0 +1,83 @@ + +// uvod +using Hra_OOP; + +internal class Program +{ + private static void Main(string[] args) + { + Console.WriteLine("Vitaj v mojej novej hre!"); + Console.WriteLine("Budes hrat 'Hviezdne vojny' no v mojej LEPSEJ verzii."); + Console.WriteLine("Budes bojovat proti vesmirnym lodiam a bude to priebiehat v kolach."); + Console.WriteLine("V 1. kole ta bude cakat normalna lod ale v 2. kole to bude boss."); + Console.WriteLine("Tvojou ulohou je porazit vsetky lode a dostat sa na koniec."); + Console.WriteLine("Prajem vela stastia!"); + + MojCharacter hrac = new MojCharacter(); + monster nepriatel = new monster(); + Boss boss = new Boss(); + // + + + //zvolenie si svojho charaktera a nepriatela + Console.WriteLine("Zadaj meno svojho charakteru (lode): "); + string characterName = Console.ReadLine(); + Console.WriteLine($"Takze tvoj character (lod) sa vola {characterName}."); + + + Console.WriteLine("Zadaj meno svojho nepriatela: "); + string monsterName = Console.ReadLine(); + Console.WriteLine($"Takze tvoj neporiatel sa vola {monsterName}."); + // + + + //1 arena + Console.WriteLine("Okay. Ideme na to!"); + Console.WriteLine("stlac enter pre spustenie utoku!"); + Console.ReadLine(); + + while (nepriatel.GetCurrentHp() > 0 && hrac.GetCurrentHp() > 0) + { + nepriatel.DealDamage(hrac); + Console.WriteLine($"{monsterName} zaútočil na {characterName}!"); + Console.WriteLine($"{characterName} má ešte {hrac.GetCurrentHp()} životov."); + + if (hrac.GetCurrentHp() <= 0) + { + Console.WriteLine($"Gratulujem! Porazil si {characterName}!"); + break; + } + + hrac.DealDamage(nepriatel); + Console.WriteLine($"{characterName} zaútočil na {monsterName}!"); + Console.WriteLine($"{monsterName} má ešte {nepriatel.GetCurrentHp()} životov."); + } + + + // zvolenie si bossa + Console.WriteLine("Takze ideme do finale!"); + Console.WriteLine("Najskor zadaj meno svojho bossa: "); + string bossName = Console.ReadLine(); + Console.WriteLine($"Takze tvoj boss sa vola {bossName}"); + // + + // utok boss + Console.WriteLine("Ideme na to!"); + Console.WriteLine("Stalc enter pre spustenie utoku: "); + Console.ReadLine(); + + while (boss.GetCurrentHp() > 0 && hrac.GetCurrentHp() > 0) + { + boss.DealDamage(hrac); + Console.WriteLine($"{bossName} zaútočil na {characterName}!"); + Console.WriteLine($"{characterName} má ešte {hrac.GetCurrentHp()} životov."); + + if (hrac.GetCurrentHp() <= 0) + { + Console.WriteLine($"Porazil si bossa {characterName}! Vyhral si hru!"); + break; + } + } + // + } +} diff --git a/Hra_OOP/character1.cs b/Hra_OOP/character1.cs new file mode 100644 index 00000000..2ec68a3a --- /dev/null +++ b/Hra_OOP/character1.cs @@ -0,0 +1,21 @@ + +namespace Hra_OOP +{ + public class character + { + internal static void DealDamage(monster monster) + { + throw new NotImplementedException(); + } + + internal void SetName(string? characterName) + { + throw new NotImplementedException(); + } + + internal void TakeDamage(int monsterDamage) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Hra_OOP/monster1.cs b/Hra_OOP/monster1.cs new file mode 100644 index 00000000..c8482a21 --- /dev/null +++ b/Hra_OOP/monster1.cs @@ -0,0 +1,39 @@ + +using Hra_OOP; + +public class monster + +{ + private const int monsterHealth = 400; + private const int minHealth1 = 0; + + private int currentHp1 = monsterHealth; + private int monsterDamage = 50; + private object name1; + monster nepriatel = new monster(); + + + public bool DealDamage(MojCharacter opponent) + { + opponent.TakeDamage(monsterDamage); + return true; + } + + public void TakeDamage(int monsterDamage) + { + currentHp1 -= monsterDamage; + if (currentHp1 < minHealth1) currentHp1 = minHealth1; + } + + public int GetCurrentHp() + { + return currentHp1; + } + + public override bool Equals(object? obj) + { + return obj is monster monster && + name1 == monster.name1; + } +} + \ No newline at end of file diff --git a/OOP_2/Animal.cs b/OOP_2/Animal.cs new file mode 100644 index 00000000..08912976 --- /dev/null +++ b/OOP_2/Animal.cs @@ -0,0 +1,24 @@ + +namespace OOP_2_ +{ + internal class Animal + { + public bool bylinozravec = false; + public void setfood(bool SiBylinozravec) + { + bylinozravec = SiBylinozravec; + + } + public bool CanEatOtherAnimal() + { + if (bylinozravec == true) + { + return false; + } + else + { + return true; + } + } + } +} diff --git a/OOP_2/Masozravec.cs b/OOP_2/Masozravec.cs new file mode 100644 index 00000000..fdfec7f8 --- /dev/null +++ b/OOP_2/Masozravec.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OOP_2_ +{ + internal class Masozravec + { + } +} diff --git a/OOP_2/OOP_2..csproj b/OOP_2/OOP_2..csproj new file mode 100644 index 00000000..cf6c7efe --- /dev/null +++ b/OOP_2/OOP_2..csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + OOP_2_ + enable + enable + + + diff --git a/OOP_2/Program.cs b/OOP_2/Program.cs new file mode 100644 index 00000000..1081bfbb --- /dev/null +++ b/OOP_2/Program.cs @@ -0,0 +1,18 @@ +// trieda Animal +// 2 zvierata +// 1. bude masozrave +// 2. bude bylinozrave +// bylino zie ine zviera +// maso zie ine zviera + +using OOP_2_; + +Animal bylinozravec = new Animal(); +bylinozravec.setfood(true); +Animal masozravec = new Animal(); +masozravec.setfood(false); + +bool MozeBylinozravecJest = bylinozravec.CanEatOtherAnimal(); +bool MozeMasozravecJest = masozravec.CanEatOtherAnimal(); +Console.WriteLine($"bylinozravec {MozeBylinozravecJest}"); +Console.WriteLine($"masozravec {MozeMasozravecJest}"); \ No newline at end of file diff --git a/OOP_2/bylinozravec.cs b/OOP_2/bylinozravec.cs new file mode 100644 index 00000000..13a893ae --- /dev/null +++ b/OOP_2/bylinozravec.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OOP_2_ +{ + internal class bylinozravec + { + } +} diff --git a/OOP_3/OOP_3..csproj b/OOP_3/OOP_3..csproj new file mode 100644 index 00000000..67b8b3fa --- /dev/null +++ b/OOP_3/OOP_3..csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + OOP_3_ + enable + enable + + + diff --git a/OOP_3/Program.cs b/OOP_3/Program.cs new file mode 100644 index 00000000..e035dda0 --- /dev/null +++ b/OOP_3/Program.cs @@ -0,0 +1,13 @@ +// trieda student +// bude mat meno, vek +// zistite od studenta ci moze legalne pit alkohol +// nastavit jeho meno +// ked bude mat jeho meno tak co moze alebo nemkze pit alkohol + + +using OOP_3_; + +string StudentName = Console.ReadLine(); + +Student Matej = new Student(); +Matej.SetName(StudentName); diff --git a/OOP_3/Student.cs b/OOP_3/Student.cs new file mode 100644 index 00000000..74a20383 --- /dev/null +++ b/OOP_3/Student.cs @@ -0,0 +1,34 @@ + + +using OOP_3_; + +namespace OOP_3_ +{ + public class Student + { + public bool student = false; + public string Name; + + public bool CanDrinkAlcohol() + { + if (student == true) + { + return false; + } + else + { + return true; + } + } + + internal void SetName(string? studentName) + { + Name = studentName; + } + } +} + + + + + diff --git a/OOP_3/student1.cs b/OOP_3/student1.cs new file mode 100644 index 00000000..4ae3a12a --- /dev/null +++ b/OOP_3/student1.cs @@ -0,0 +1,11 @@ +// trieda student +// bude mat meno, vek +// zistite od studenta ci moze legalne pit alkohol +// nastavit jeho meno +// ked bude mat jeho meno tak co moze alebo nemkze pit alkohol + + +internal class student +{ + public static bool CanDrinkAlcohol { get; internal set; } +} \ No newline at end of file diff --git a/src/AppsLab-020-OOP/Monster.cs b/src/AppsLab-020-OOP/Monster.cs new file mode 100644 index 00000000..179b4ee1 --- /dev/null +++ b/src/AppsLab-020-OOP/Monster.cs @@ -0,0 +1,23 @@ + + +namespace AppsLab_020_OOP +{ + public class Monster + { + private const int maxHp = 200; + private const int minHp = 0; + + private int currentHp = maxHp; + private int MonsterDamage = 1; + + internal void TakeDamage(int MonsterDamage) + { + currentHp -= MonsterDamage; + } + public bool DealDamage(Player opponent) + { + opponent.TakeDamage(MonsterDamage); + return true; + } + } +} \ No newline at end of file diff --git a/src/AppsLab-020-OOP/Player.cs b/src/AppsLab-020-OOP/Player.cs new file mode 100644 index 00000000..48babc44 --- /dev/null +++ b/src/AppsLab-020-OOP/Player.cs @@ -0,0 +1,36 @@ + + + + + +namespace AppsLab_020_OOP +{ + public class Player + { + private const int maxHp = 100; + private const int minHp = 0; + + private string Name; + private int currentHp = maxHp; + private int PlayerDamage = 20; + private List inventory = new List(); + + + public bool DealDamage( Monster opponent) + { + opponent.TakeDamage(PlayerDamage); + return true; + } + + public void SetName(string? PlayerName) + { + Name = PlayerName; + } + + public void TakeDamage(int PlayerDamage) + { + int currnetHp = PlayerDamage; + } + } +} + diff --git a/src/AppsLab-020-OOP/Program.cs b/src/AppsLab-020-OOP/Program.cs index 3751555c..392925b7 100644 --- a/src/AppsLab-020-OOP/Program.cs +++ b/src/AppsLab-020-OOP/Program.cs @@ -1,2 +1,11 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +using AppsLab_020_OOP; + +string PlayerName = Console.ReadLine(); + +Player Matej = new Player(); +Matej.SetName(PlayerName); + +Monster monster = new Monster(); + +Matej.DealDamage(monster); +monster.DealDamage(Matej); \ No newline at end of file From fdd938ae8dc3d9a0a32ea177c804d0893baffb11 Mon Sep 17 00:00:00 2001 From: Matej Kolkus Date: Tue, 4 Nov 2025 16:47:47 +0100 Subject: [PATCH 21/21] Hra OOP 2. --- Hra_OOP/Character.cs | 31 ----------------------------- Hra_OOP/Monster.cs | 41 --------------------------------------- Hra_OOP/Player.cs | 29 ---------------------------- Hra_OOP/Prisera.cs | 45 ------------------------------------------- Hra_OOP/character1.cs | 21 -------------------- 5 files changed, 167 deletions(-) delete mode 100644 Hra_OOP/Character.cs delete mode 100644 Hra_OOP/Monster.cs delete mode 100644 Hra_OOP/Player.cs delete mode 100644 Hra_OOP/Prisera.cs delete mode 100644 Hra_OOP/character1.cs diff --git a/Hra_OOP/Character.cs b/Hra_OOP/Character.cs deleted file mode 100644 index b494be77..00000000 --- a/Hra_OOP/Character.cs +++ /dev/null @@ -1,31 +0,0 @@ - -namespace Hra_OOP -{ - public class Character - { - internal void DealDamage(Monster enemy) - { - throw new NotImplementedException(); - } - - internal object GetName() - { - throw new NotImplementedException(); - } - - internal bool IsAlive() - { - throw new NotImplementedException(); - } - - internal void TakeDamage(int monsterDamage) - { - throw new NotImplementedException(); - } - - public static implicit operator Character(MojCharacter v) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/Hra_OOP/Monster.cs b/Hra_OOP/Monster.cs deleted file mode 100644 index f9bc80e7..00000000 --- a/Hra_OOP/Monster.cs +++ /dev/null @@ -1,41 +0,0 @@ - -namespace Hra_OOP -{ - public class Monster - { - internal static void DealDamage(Player name) - { - throw new NotImplementedException(); - } - - internal void DealDamage(Character hero) - { - throw new NotImplementedException(); - } - - internal object GetName() - { - throw new NotImplementedException(); - } - - internal bool IsAlive() - { - throw new NotImplementedException(); - } - - internal void SetName(object monsterName) - { - throw new NotImplementedException(); - } - - internal void TakeDamage(int characterDamage) - { - throw new NotImplementedException(); - } - - public static implicit operator Monster(monster v) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/Hra_OOP/Player.cs b/Hra_OOP/Player.cs deleted file mode 100644 index b83bee9b..00000000 --- a/Hra_OOP/Player.cs +++ /dev/null @@ -1,29 +0,0 @@ - -using Hra_OOP; - -internal class Player -{ - public Player() - { - } - - internal void DealDamage(Monster monster) - { - throw new NotImplementedException(); - } - - internal void DealDamage(monster name1) - { - throw new NotImplementedException(); - } - - internal void SetName(string? characterName) - { - throw new NotImplementedException(); - } - - internal void SetName(object playerName) - { - throw new NotImplementedException(); - } -} \ No newline at end of file diff --git a/Hra_OOP/Prisera.cs b/Hra_OOP/Prisera.cs deleted file mode 100644 index 2751d619..00000000 --- a/Hra_OOP/Prisera.cs +++ /dev/null @@ -1,45 +0,0 @@ - - - -namespace Hra_OOP -{ - public class Prisera - { - private const int maxHp = 400; - private const int minHp = 0; - - private string name; - private int currentHp = maxHp; - private int monsterDamage = 50; - private List monster = new List(); - - public object name1 { get; private set; } - public object monsterName { get; private set; } - - public bool DealDamage(character opponent) - { - opponent.TakeDamage(monsterDamage); - return true; - } - - public void SetName(string? playerName) - { - name1 = monsterName; - } - - public void TakeDamage(int playerDamage) - { - int currnetHp = playerDamage; - } - - public int GetCurrentHp() - { - return currentHp; - } - - public string GetName() - { - return name; - } - } -} diff --git a/Hra_OOP/character1.cs b/Hra_OOP/character1.cs deleted file mode 100644 index 2ec68a3a..00000000 --- a/Hra_OOP/character1.cs +++ /dev/null @@ -1,21 +0,0 @@ - -namespace Hra_OOP -{ - public class character - { - internal static void DealDamage(monster monster) - { - throw new NotImplementedException(); - } - - internal void SetName(string? characterName) - { - throw new NotImplementedException(); - } - - internal void TakeDamage(int monsterDamage) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file