From 1d5e0c4437a176fdc198a2b1e3b4001af2e8d55e Mon Sep 17 00:00:00 2001 From: David Choluj Date: Wed, 10 Sep 2025 11:00:56 +0200 Subject: [PATCH 1/9] changed /Hello World/ > Hello AppsLab --- src/AppsLab-001-StartHere/Greetings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppsLab-001-StartHere/Greetings.cs b/src/AppsLab-001-StartHere/Greetings.cs index fbe10953..f02fdb12 100644 --- a/src/AppsLab-001-StartHere/Greetings.cs +++ b/src/AppsLab-001-StartHere/Greetings.cs @@ -11,6 +11,6 @@ public class Greetings /// A string containing the greeting message. public string Hello() { - return "Hello World!"; + return "Hello AppsLab!"; } } From 50b6574b908aa7c20fe1de35f4ca5696fcf61012 Mon Sep 17 00:00:00 2001 From: David Choluj Date: Wed, 10 Sep 2025 11:39:22 +0200 Subject: [PATCH 2/9] =?UTF-8?q?tak=C5=BEe=20-=20tu=20tento=20k=C3=B3d=20vy?= =?UTF-8?q?p=C3=AD=C5=A1e=20tvoj=20vek=20a=20meno?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppsLab-002-ConsoleWriteLine/Program.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/AppsLab-002-ConsoleWriteLine/Program.cs b/src/AppsLab-002-ConsoleWriteLine/Program.cs index 837131c2..f8fa6994 100644 --- a/src/AppsLab-002-ConsoleWriteLine/Program.cs +++ b/src/AppsLab-002-ConsoleWriteLine/Program.cs @@ -1 +1,3 @@ -Console.WriteLine("Hello, World!"); \ No newline at end of file +int age = 1024; +string name = "Neviem"; +Console.WriteLine($"The name is {name} and I am {age} years old, I am young"); \ No newline at end of file From de9e6c6ec24bc17f083e5d839496b9de5497b56b Mon Sep 17 00:00:00 2001 From: David Choluj Date: Wed, 24 Sep 2025 09:25:42 +0200 Subject: [PATCH 3/9] trochu som skusal --- AppsLab.CSharp.Exercises.sln | 21 ++++++--------------- src/AppsLab-005-DataTypes/Program.cs | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index 58bbf6b5..3b53985a 100644 --- a/AppsLab.CSharp.Exercises.sln +++ b/AppsLab.CSharp.Exercises.sln @@ -94,9 +94,6 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppsLab-034-Debug", "src\AppsLab-034-Debug\AppsLab-034-Debug.csproj", "{83C963FD-DC23-46E8-9545-F56197164810}" EndProject Global - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 @@ -226,18 +223,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 @@ -635,6 +620,9 @@ Global {83C963FD-DC23-46E8-9545-F56197164810}.Release|x86.ActiveCfg = Release|Any CPU {83C963FD-DC23-46E8-9545-F56197164810}.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} {FE64EA2A-841F-49D7-94C6-BB7E50FC972D} = {FC89E9B9-1723-4328-B6F1-00EE62E6260F} @@ -680,4 +668,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 = {31F49123-4C4A-4A0F-8756-A7035ED3F281} + EndGlobalSection EndGlobal diff --git a/src/AppsLab-005-DataTypes/Program.cs b/src/AppsLab-005-DataTypes/Program.cs index 3751555c..8738a130 100644 --- a/src/AppsLab-005-DataTypes/Program.cs +++ b/src/AppsLab-005-DataTypes/Program.cs @@ -1,2 +1,15 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +float neviem = 0.11111f; +int mojeCislo = 123456; +string mojeSlovo = "Hello World"; +bool mojaBoolHodnota = true; +DateTime dnesnyDatum = DateTime.Now; +var neviem2 = "dfghjk"; +int sucet = mojeCislo + 5; + +Console.WriteLine(mojeCislo); +Console.WriteLine(mojeSlovo); +Console.WriteLine(dnesnyDatum.ToString("yyyy.MM.dd")); +Console.WriteLine(mojaBoolHodnota); +Console.WriteLine(sucet); +Console.WriteLine($"Hodnota Float je:{neviem}"); +Console.WriteLine(neviem2); \ No newline at end of file From 4eb8321c0299ce90912ce2dfc9d10d93f2b1e5e3 Mon Sep 17 00:00:00 2001 From: David Choluj Date: Wed, 24 Sep 2025 10:02:40 +0200 Subject: [PATCH 4/9] text 123n --- src/AppsLab-005-DataTypes/Program.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/AppsLab-005-DataTypes/Program.cs b/src/AppsLab-005-DataTypes/Program.cs index 8738a130..fb7f07b1 100644 --- a/src/AppsLab-005-DataTypes/Program.cs +++ b/src/AppsLab-005-DataTypes/Program.cs @@ -5,6 +5,13 @@ DateTime dnesnyDatum = DateTime.Now; var neviem2 = "dfghjk"; int sucet = mojeCislo + 5; +const int MaxStudents = 15; + + + + + +Console.WriteLine("Maximlany pocet ziakov v triede je:" + MaxStudents); Console.WriteLine(mojeCislo); Console.WriteLine(mojeSlovo); From 0be28cdcc80cd2dad5745d01ae4f345031256a6b Mon Sep 17 00:00:00 2001 From: David Choluj Date: Wed, 24 Sep 2025 10:44:09 +0200 Subject: [PATCH 5/9] Zfgh --- src/AppsLab-006-Constants/Program.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/AppsLab-006-Constants/Program.cs b/src/AppsLab-006-Constants/Program.cs index 3751555c..95e84a05 100644 --- a/src/AppsLab-006-Constants/Program.cs +++ b/src/AppsLab-006-Constants/Program.cs @@ -1,2 +1,7 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +const int MaxPoints = 100; +const int MinAgeForDrivingLicence = 17; +const string WelcomeMessage = "Vitajte tu v tomto teste"; + +Console.WriteLine(MaxPoints); +Console.WriteLine(MinAgeForDrivingLicence); +Console.WriteLine(WelcomeMessage); \ No newline at end of file From 763b85b5675b23c8c51e56659ab93b7690be6358 Mon Sep 17 00:00:00 2001 From: David Choluj Date: Wed, 24 Sep 2025 13:01:41 +0200 Subject: [PATCH 6/9] ^ --- src/AppsLab-007-Casting/Converter.cs | 48 +++++++--------------- src/AppsLab-008-ConsoleReadLine/Program.cs | 11 +++-- 2 files changed, 22 insertions(+), 37 deletions(-) diff --git a/src/AppsLab-007-Casting/Converter.cs b/src/AppsLab-007-Casting/Converter.cs index a64ce567..1dcc4dd1 100644 --- a/src/AppsLab-007-Casting/Converter.cs +++ b/src/AppsLab-007-Casting/Converter.cs @@ -1,63 +1,45 @@ namespace AppsLab_007_Casting; -/// -/// This class contains methods to convert between different data types. -/// public class Converter { - /// - /// This method converts a string to an integer. - /// + public double IntToDouble(int number) { - throw new NotImplementedException(); + + return Convert.ToDouble(number); } - /// - /// This method converts a double to an integer. - /// public int DoubleToInt(double number) { - throw new NotImplementedException(); + return Convert.ToInt(number); } - - /// - /// This method converts a string to a double. - /// + public double StringToDouble(string number) { - throw new NotImplementedException(); + return Convert.ToDouble(number); } - /// - /// This method converts a double to a string. - /// + public string DoubleToString(double number) { - throw new NotImplementedException(); + return Convert.ToString(number); } - /// - /// This method converts a string to a boolean. - /// + public string IntToString(int number) { - throw new NotImplementedException(); + return Convert.ToString(number); } - /// - /// This method converts a boolean to a string. - /// + public bool StringToBool(string boolValue) { - throw new NotImplementedException(); + return Convert.ToBool(boolValue); } - /// - /// This method converts a boolean to a string. - /// - public string BoolToString(bool boolValue) + + public string StringToBool(bool boolValue) { - throw new NotImplementedException(); + return Convert.ToBool(boolValue); } } diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 6f7376c9..0d49a591 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -1,8 +1,11 @@ -Console.WriteLine("Ako sa voláš?"); +Console.WriteLine("Ako sa ty voláš"); string? meno = Console.ReadLine(); -Console.WriteLine("Ahoj, " + meno); +Console.WriteLine("Ahoj, " + meno + " Koľko máš rokov"); -Console.WriteLine("Koľko máš rokov?"); string vstup = Console.ReadLine() ?? "0"; int vek = int.Parse(vstup); -Console.WriteLine("Máš " + vek + " rokov."); +Console.WriteLine("Aha,máš teda " + vek + " rokov."); + +Console.WriteLine("Jake je tvoje oblubene jedlo?"); +string? jedlo = Console.ReadLine(); +Console.WriteLine("Hmm " + jedlo + "znie skvelo!!"); \ No newline at end of file From 99ae45c810dbab6c5a900b5cbd4cc3a7bf9c90b9 Mon Sep 17 00:00:00 2001 From: David Choluj Date: Sat, 4 Oct 2025 19:04:50 +0200 Subject: [PATCH 7/9] moja du co mi dal Martin K. na praxi --- AppsLab.CSharp.Exercises.sln | 30 ++++++++++++ ConsoleApp1/ConsoleApp1.csproj | 10 ++++ ConsoleApp1/Program.cs | 36 ++++++++++++++ domaci coding for fun/Program.cs | 38 ++++++++++++++ .../domaci coding for fun.csproj | 11 +++++ homework/Program.cs | 39 +++++++++++++++ homework/homework.csproj | 10 ++++ src/AppsLab-008-ConsoleReadLine/Program.cs | 49 +++++++++++++++---- 8 files changed, 214 insertions(+), 9 deletions(-) create mode 100644 ConsoleApp1/ConsoleApp1.csproj create mode 100644 ConsoleApp1/Program.cs create mode 100644 domaci coding for fun/Program.cs create mode 100644 domaci coding for fun/domaci coding for fun.csproj create mode 100644 homework/Program.cs create mode 100644 homework/homework.csproj diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index 3b53985a..b888247a 100644 --- a/AppsLab.CSharp.Exercises.sln +++ b/AppsLab.CSharp.Exercises.sln @@ -93,6 +93,10 @@ 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}") = "domaci coding for fun", "domaci coding for fun\domaci coding for fun.csproj", "{2DC7B273-3458-423E-880C-A8B9139642AF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "homework", "homework\homework.csproj", "{CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -619,6 +623,30 @@ 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 + {2DC7B273-3458-423E-880C-A8B9139642AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2DC7B273-3458-423E-880C-A8B9139642AF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2DC7B273-3458-423E-880C-A8B9139642AF}.Debug|x64.ActiveCfg = Debug|Any CPU + {2DC7B273-3458-423E-880C-A8B9139642AF}.Debug|x64.Build.0 = Debug|Any CPU + {2DC7B273-3458-423E-880C-A8B9139642AF}.Debug|x86.ActiveCfg = Debug|Any CPU + {2DC7B273-3458-423E-880C-A8B9139642AF}.Debug|x86.Build.0 = Debug|Any CPU + {2DC7B273-3458-423E-880C-A8B9139642AF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2DC7B273-3458-423E-880C-A8B9139642AF}.Release|Any CPU.Build.0 = Release|Any CPU + {2DC7B273-3458-423E-880C-A8B9139642AF}.Release|x64.ActiveCfg = Release|Any CPU + {2DC7B273-3458-423E-880C-A8B9139642AF}.Release|x64.Build.0 = Release|Any CPU + {2DC7B273-3458-423E-880C-A8B9139642AF}.Release|x86.ActiveCfg = Release|Any CPU + {2DC7B273-3458-423E-880C-A8B9139642AF}.Release|x86.Build.0 = Release|Any CPU + {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}.Debug|x64.ActiveCfg = Debug|Any CPU + {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}.Debug|x64.Build.0 = Debug|Any CPU + {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}.Debug|x86.ActiveCfg = Debug|Any CPU + {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}.Debug|x86.Build.0 = Debug|Any CPU + {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}.Release|Any CPU.Build.0 = Release|Any CPU + {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}.Release|x64.ActiveCfg = Release|Any CPU + {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}.Release|x64.Build.0 = Release|Any CPU + {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}.Release|x86.ActiveCfg = Release|Any CPU + {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -667,6 +695,8 @@ 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} + {2DC7B273-3458-423E-880C-A8B9139642AF} = {56555FB0-B513-49EF-9002-A5AF135EA090} + {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1} = {56555FB0-B513-49EF-9002-A5AF135EA090} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {31F49123-4C4A-4A0F-8756-A7035ED3F281} 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/ConsoleApp1/Program.cs b/ConsoleApp1/Program.cs new file mode 100644 index 00000000..2325680a --- /dev/null +++ b/ConsoleApp1/Program.cs @@ -0,0 +1,36 @@ + +string cislo1 = Console.ReadLine (); +decimal prvecislo = decimal.Parse (cislo1); +string operacia = Console.ReadLine(); +string cislo2 = Console.ReadLine(); +decimal druhecislo = decimal.Parse (cislo2); + +if (operacia == "-") +{ + decimal vysledok = prvecislo - druhecislo; + Console.WriteLine($"vysledok je {vysledok}"); +} + +else if (operacia == "+") +{ + decimal vysledok = prvecislo + druhecislo; + Console.WriteLine($"Vysledok je {vysledok}."); +} + +else if (operacia == "*") +{ + decimal vysledok = prvecislo * druhecislo; + Console.WriteLine($"Vysledok je{vysledok}."); +} +else if (operacia == "/") +{ + decimal vysledok = prvecislo / druhecislo; + Console.WriteLine($"Vysledok je {vysledok}"); +} + +else if (operacia == "%") +{ + decimal vysledok = prvecislo % druhecislo; + Console.WriteLine($"Vysledok je:{vysledok}."); +} +Console.WriteLine("dakujem ze si pouzil moju kalkulacku dovidenia"); \ No newline at end of file diff --git a/domaci coding for fun/Program.cs b/domaci coding for fun/Program.cs new file mode 100644 index 00000000..1fcdb668 --- /dev/null +++ b/domaci coding for fun/Program.cs @@ -0,0 +1,38 @@ +string number1 = Console.ReadLine(); +decimal cislo1 = Convert.ToDecimal(number1); +string operation = Console.ReadLine(); +string number2 = Console.ReadLine(); +decimal cislo2 = Convert.ToDecimal(number2); + +// scitovanie + +if (operation == +) +{ + odpoved = cislo1 + cislo2; + Console.WriteLine($"vysledok je {odpoved}") +} +// odcitanie + +else if (operation == -) +{ + odpoved = cislo1 - cislo2; + Console.WriteLine(odpoved); + +} + +// nasobenie + +else if (operation == *) +{ + odpoved = cislo1 * cislo2; + Console.WriteLine(odpoved); + +} + +// delenie +else if (operation == "/") +{ + odpoved = (cislo1 / cislo2); + Console.WriteLine(odpoved); + +} \ No newline at end of file diff --git a/domaci coding for fun/domaci coding for fun.csproj b/domaci coding for fun/domaci coding for fun.csproj new file mode 100644 index 00000000..ae46458c --- /dev/null +++ b/domaci coding for fun/domaci coding for fun.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + domaci_coding_for_fun + enable + enable + + + diff --git a/homework/Program.cs b/homework/Program.cs new file mode 100644 index 00000000..9dce1fe0 --- /dev/null +++ b/homework/Program.cs @@ -0,0 +1,39 @@ +Console.WriteLine("Zadaj cislo 1"); +string number1 = Console.ReadLine(); +decimal cislo1 = decimal.Parse(number1); +Console.WriteLine("Zadaj operaciu"); +string operacia = Console.ReadLine(); +Console.WriteLine("Zadaj cislo 2"); +string number2 = Console.ReadLine(); +decimal cislo2 = decimal.Parse(number2); + +if (operacia == "+") +{ + decimal vysledok = (cislo1 + cislo2); + Console.WriteLine($"vysledok je {vysledok}"); +} + +else if (operacia == "-") +{ + decimal vysledok = (cislo1 - cislo2); + Console.WriteLine($"vysledok je {vysledok}"); +} + +else if (operacia == "*") +{ + decimal vysledok =(cislo1 * cislo2); + Console.WriteLine($"vysledok je {vysledok}"); +} + +else if(operacia == "/") +{ + decimal vysledok =(cislo1 / cislo2); + Console.WriteLine($"vysledok je {vysledok}"); +} + +else if (operacia == "%") +{ + decimal vysledok = (cislo1 % cislo2); + Console.WriteLine($"zvysek je {vysledok}"); +} +Console.WriteLine("dakujem ze si pouzil moju kalkulacku, dovidenia"); \ No newline at end of file diff --git a/homework/homework.csproj b/homework/homework.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/homework/homework.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 0d49a591..5362db85 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -1,11 +1,42 @@ -Console.WriteLine("Ako sa ty voláš"); -string? meno = Console.ReadLine(); -Console.WriteLine("Ahoj, " + meno + " Koľko máš rokov"); + +//Console.WriteLine("Ahoj, cislo c. 1"); +//string? number1 = Console.ReadLine(); +//Console.WriteLine("zadaj druhe cislo:"); +//string? number2 = Console.ReadLine(); + + +//Console.WriteLine("zadaj operaciu + alebo -"); +//string? operacia = Console.ReadLine(); + +//if (operacia = +//int vysledok = int.Parse(number1) - int.Parse(number2); +//Console.WriteLine($"Vysledok je{vysledok}."); +//if operacia = "+"; + +//int vysledok = int.Parse(number1) + int.Parse(number2); + + +//Console.WriteLine($"Vysledok je{vysledok}."); + + + + + + + + + + + + + + + + + + + + + -string vstup = Console.ReadLine() ?? "0"; -int vek = int.Parse(vstup); -Console.WriteLine("Aha,máš teda " + vek + " rokov."); -Console.WriteLine("Jake je tvoje oblubene jedlo?"); -string? jedlo = Console.ReadLine(); -Console.WriteLine("Hmm " + jedlo + "znie skvelo!!"); \ No newline at end of file From 1a5f779c3c1319cf6f05394bff8b0b1239985b4e Mon Sep 17 00:00:00 2001 From: David Choluj Date: Wed, 8 Oct 2025 09:41:00 +0200 Subject: [PATCH 8/9] moja nova kalkulacka so swithconm --- homework/Program.cs | 55 ++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/homework/Program.cs b/homework/Program.cs index 9dce1fe0..c3765924 100644 --- a/homework/Program.cs +++ b/homework/Program.cs @@ -1,39 +1,38 @@ Console.WriteLine("Zadaj cislo 1"); string number1 = Console.ReadLine(); decimal cislo1 = decimal.Parse(number1); -Console.WriteLine("Zadaj operaciu"); +Console.WriteLine("Zadaj operaciu +-/%"); string operacia = Console.ReadLine(); Console.WriteLine("Zadaj cislo 2"); string number2 = Console.ReadLine(); decimal cislo2 = decimal.Parse(number2); -if (operacia == "+") +decimal vysledok = 0; +switch (operacia) { - decimal vysledok = (cislo1 + cislo2); - Console.WriteLine($"vysledok je {vysledok}"); + case "+": + vysledok = cislo1 + cislo2; + Console.WriteLine(vysledok); + break; + case "-": + vysledok = cislo2 - cislo2; + Console.WriteLine(vysledok); + break; + case "/": + if (cislo2 == 0) + { + Console.WriteLine("ty magor nulou sa neda delit"); + } + vysledok = cislo1 / cislo2; + Console.WriteLine(vysledok); + break; + case "*": + vysledok = cislo1 * cislo2; + Console.WriteLine(vysledok); + break; + case "%": + vysledok = (cislo1 / cislo2); + Console.WriteLine(vysledok); + break; } -else if (operacia == "-") -{ - decimal vysledok = (cislo1 - cislo2); - Console.WriteLine($"vysledok je {vysledok}"); -} - -else if (operacia == "*") -{ - decimal vysledok =(cislo1 * cislo2); - Console.WriteLine($"vysledok je {vysledok}"); -} - -else if(operacia == "/") -{ - decimal vysledok =(cislo1 / cislo2); - Console.WriteLine($"vysledok je {vysledok}"); -} - -else if (operacia == "%") -{ - decimal vysledok = (cislo1 % cislo2); - Console.WriteLine($"zvysek je {vysledok}"); -} -Console.WriteLine("dakujem ze si pouzil moju kalkulacku, dovidenia"); \ No newline at end of file From bb6cf5bdf09dd1f386dc186aca64a58a91c5ee96 Mon Sep 17 00:00:00 2001 From: David Choluj Date: Wed, 8 Oct 2025 10:56:44 +0200 Subject: [PATCH 9/9] dnesny commit --- AppsLab.CSharp.Exercises.sln | 30 ----- domaci coding for fun/Program.cs | 39 +----- ...r fun.csproj => domacicodingforfun.csproj} | 0 homework/Program.cs | 37 ++---- src/AppsLab-007-Casting/Converter.cs | 64 +++++----- src/AppsLab-014-Switch/MovieRating.cs | 20 ++- .../ConverterTests.cs | 116 +++++++++--------- 7 files changed, 119 insertions(+), 187 deletions(-) rename domaci coding for fun/{domaci coding for fun.csproj => domacicodingforfun.csproj} (100%) diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index b888247a..d47441a8 100644 --- a/AppsLab.CSharp.Exercises.sln +++ b/AppsLab.CSharp.Exercises.sln @@ -21,8 +21,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppsLab-007-Casting", "src\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppsLab-007-Casting.Tests", "tests\AppsLab-007-Casting.Tests\AppsLab-007-Casting.Tests.csproj", "{5B78F61E-B52C-4920-BE97-42AADFAA726F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppsLab-008-ConsoleReadLine", "src\AppsLab-008-ConsoleReadLine\AppsLab-008-ConsoleReadLine.csproj", "{5314C734-E722-4454-A772-D0F4641E1563}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppsLab-009-Operators", "src\AppsLab-009-Operators\AppsLab-009-Operators.csproj", "{B6030D54-19E2-40EF-8C93-17669CEC23E0}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppsLab-009-Operators.Tests", "tests\AppsLab-009-Operators.Tests\AppsLab-009-Operators.Tests.csproj", "{A6659FD2-5F11-432B-91B7-C64EAEAF669C}" @@ -93,8 +91,6 @@ 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}") = "domaci coding for fun", "domaci coding for fun\domaci coding for fun.csproj", "{2DC7B273-3458-423E-880C-A8B9139642AF}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "homework", "homework\homework.csproj", "{CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}" EndProject Global @@ -191,18 +187,6 @@ Global {5B78F61E-B52C-4920-BE97-42AADFAA726F}.Release|x64.Build.0 = Release|Any CPU {5B78F61E-B52C-4920-BE97-42AADFAA726F}.Release|x86.ActiveCfg = Release|Any CPU {5B78F61E-B52C-4920-BE97-42AADFAA726F}.Release|x86.Build.0 = Release|Any CPU - {5314C734-E722-4454-A772-D0F4641E1563}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5314C734-E722-4454-A772-D0F4641E1563}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5314C734-E722-4454-A772-D0F4641E1563}.Debug|x64.ActiveCfg = Debug|Any CPU - {5314C734-E722-4454-A772-D0F4641E1563}.Debug|x64.Build.0 = Debug|Any CPU - {5314C734-E722-4454-A772-D0F4641E1563}.Debug|x86.ActiveCfg = Debug|Any CPU - {5314C734-E722-4454-A772-D0F4641E1563}.Debug|x86.Build.0 = Debug|Any CPU - {5314C734-E722-4454-A772-D0F4641E1563}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5314C734-E722-4454-A772-D0F4641E1563}.Release|Any CPU.Build.0 = Release|Any CPU - {5314C734-E722-4454-A772-D0F4641E1563}.Release|x64.ActiveCfg = Release|Any CPU - {5314C734-E722-4454-A772-D0F4641E1563}.Release|x64.Build.0 = Release|Any CPU - {5314C734-E722-4454-A772-D0F4641E1563}.Release|x86.ActiveCfg = Release|Any CPU - {5314C734-E722-4454-A772-D0F4641E1563}.Release|x86.Build.0 = Release|Any CPU {B6030D54-19E2-40EF-8C93-17669CEC23E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B6030D54-19E2-40EF-8C93-17669CEC23E0}.Debug|Any CPU.Build.0 = Debug|Any CPU {B6030D54-19E2-40EF-8C93-17669CEC23E0}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -623,18 +607,6 @@ 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 - {2DC7B273-3458-423E-880C-A8B9139642AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2DC7B273-3458-423E-880C-A8B9139642AF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2DC7B273-3458-423E-880C-A8B9139642AF}.Debug|x64.ActiveCfg = Debug|Any CPU - {2DC7B273-3458-423E-880C-A8B9139642AF}.Debug|x64.Build.0 = Debug|Any CPU - {2DC7B273-3458-423E-880C-A8B9139642AF}.Debug|x86.ActiveCfg = Debug|Any CPU - {2DC7B273-3458-423E-880C-A8B9139642AF}.Debug|x86.Build.0 = Debug|Any CPU - {2DC7B273-3458-423E-880C-A8B9139642AF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2DC7B273-3458-423E-880C-A8B9139642AF}.Release|Any CPU.Build.0 = Release|Any CPU - {2DC7B273-3458-423E-880C-A8B9139642AF}.Release|x64.ActiveCfg = Release|Any CPU - {2DC7B273-3458-423E-880C-A8B9139642AF}.Release|x64.Build.0 = Release|Any CPU - {2DC7B273-3458-423E-880C-A8B9139642AF}.Release|x86.ActiveCfg = Release|Any CPU - {2DC7B273-3458-423E-880C-A8B9139642AF}.Release|x86.Build.0 = Release|Any CPU {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}.Debug|Any CPU.Build.0 = Debug|Any CPU {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -659,7 +631,6 @@ Global {F1E80A4A-241C-496D-92D6-B047A0EAF030} = {56555FB0-B513-49EF-9002-A5AF135EA090} {AEEAB66C-8B62-4844-A721-1FA49E82FDEB} = {56555FB0-B513-49EF-9002-A5AF135EA090} {5B78F61E-B52C-4920-BE97-42AADFAA726F} = {FC89E9B9-1723-4328-B6F1-00EE62E6260F} - {5314C734-E722-4454-A772-D0F4641E1563} = {56555FB0-B513-49EF-9002-A5AF135EA090} {B6030D54-19E2-40EF-8C93-17669CEC23E0} = {56555FB0-B513-49EF-9002-A5AF135EA090} {A6659FD2-5F11-432B-91B7-C64EAEAF669C} = {FC89E9B9-1723-4328-B6F1-00EE62E6260F} {FD645D4C-9DC8-4603-A77B-8A4782F175F4} = {56555FB0-B513-49EF-9002-A5AF135EA090} @@ -695,7 +666,6 @@ Global {7BEA7878-B5BA-4480-BC56-2F7B836F64B9} = {56555FB0-B513-49EF-9002-A5AF135EA090} {38FFE1DF-4B49-40C1-9908-51860BCF2D3E} = {56555FB0-B513-49EF-9002-A5AF135EA090} {83C963FD-DC23-46E8-9545-F56197164810} = {56555FB0-B513-49EF-9002-A5AF135EA090} - {2DC7B273-3458-423E-880C-A8B9139642AF} = {56555FB0-B513-49EF-9002-A5AF135EA090} {CA90FDFB-E288-4BF3-AB5B-1493DB12F4C1} = {56555FB0-B513-49EF-9002-A5AF135EA090} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/domaci coding for fun/Program.cs b/domaci coding for fun/Program.cs index 1fcdb668..5f282702 100644 --- a/domaci coding for fun/Program.cs +++ b/domaci coding for fun/Program.cs @@ -1,38 +1 @@ -string number1 = Console.ReadLine(); -decimal cislo1 = Convert.ToDecimal(number1); -string operation = Console.ReadLine(); -string number2 = Console.ReadLine(); -decimal cislo2 = Convert.ToDecimal(number2); - -// scitovanie - -if (operation == +) -{ - odpoved = cislo1 + cislo2; - Console.WriteLine($"vysledok je {odpoved}") -} -// odcitanie - -else if (operation == -) -{ - odpoved = cislo1 - cislo2; - Console.WriteLine(odpoved); - -} - -// nasobenie - -else if (operation == *) -{ - odpoved = cislo1 * cislo2; - Console.WriteLine(odpoved); - -} - -// delenie -else if (operation == "/") -{ - odpoved = (cislo1 / cislo2); - Console.WriteLine(odpoved); - -} \ No newline at end of file + \ No newline at end of file diff --git a/domaci coding for fun/domaci coding for fun.csproj b/domaci coding for fun/domacicodingforfun.csproj similarity index 100% rename from domaci coding for fun/domaci coding for fun.csproj rename to domaci coding for fun/domacicodingforfun.csproj diff --git a/homework/Program.cs b/homework/Program.cs index c3765924..a68dfe64 100644 --- a/homework/Program.cs +++ b/homework/Program.cs @@ -7,32 +7,15 @@ string number2 = Console.ReadLine(); decimal cislo2 = decimal.Parse(number2); -decimal vysledok = 0; -switch (operacia) +decimal vysledok = operacia switch { - case "+": - vysledok = cislo1 + cislo2; - Console.WriteLine(vysledok); - break; - case "-": - vysledok = cislo2 - cislo2; - Console.WriteLine(vysledok); - break; - case "/": - if (cislo2 == 0) - { - Console.WriteLine("ty magor nulou sa neda delit"); - } - vysledok = cislo1 / cislo2; - Console.WriteLine(vysledok); - break; - case "*": - vysledok = cislo1 * cislo2; - Console.WriteLine(vysledok); - break; - case "%": - vysledok = (cislo1 / cislo2); - Console.WriteLine(vysledok); - break; -} + "+" => (cislo1 + cislo2), + "/" => (cislo1 / cislo2), + "-" => (cislo1 - cislo2), + "*" => (cislo1 * cislo2), + "%" => (cislo1 % cislo2), +}; + +Console.WriteLine(vysledok); + diff --git a/src/AppsLab-007-Casting/Converter.cs b/src/AppsLab-007-Casting/Converter.cs index 1dcc4dd1..700f6e99 100644 --- a/src/AppsLab-007-Casting/Converter.cs +++ b/src/AppsLab-007-Casting/Converter.cs @@ -1,45 +1,45 @@ -namespace AppsLab_007_Casting; +//namespace AppsLab_007_Casting; -public class Converter -{ +//public class Converter +//{ - public double IntToDouble(int number) - { +// public double IntToDouble(int number) +// { - return Convert.ToDouble(number); - } +// return Convert.ToDouble(number); +// } - public int DoubleToInt(double number) - { - return Convert.ToInt(number); - } +// public int DoubleToInt(double number) +// { +// return Convert.ToInt(number); +// } - public double StringToDouble(string number) - { - return Convert.ToDouble(number); - } +// public double StringToDouble(string number) +// { +// return Convert.ToDouble(number); +// } - public string DoubleToString(double number) - { - return Convert.ToString(number); - } +// public string DoubleToString(double number) +// { +// return Convert.ToString(number); +// } - public string IntToString(int number) - { - return Convert.ToString(number); - } +// public string IntToString(int number) +// { +// return Convert.ToString(number); +// } - public bool StringToBool(string boolValue) - { - return Convert.ToBool(boolValue); - } +// public bool StringToBool(string boolValue) +// { +// return Convert.ToBool(boolValue); +// } - public string StringToBool(bool boolValue) - { - return Convert.ToBool(boolValue); - } -} +// public string StringToBool(bool boolValue) +// { +// return Convert.ToBool(boolValue); +// } +//} diff --git a/src/AppsLab-014-Switch/MovieRating.cs b/src/AppsLab-014-Switch/MovieRating.cs index ab689d49..7fe09f4b 100644 --- a/src/AppsLab-014-Switch/MovieRating.cs +++ b/src/AppsLab-014-Switch/MovieRating.cs @@ -12,6 +12,22 @@ public class MovieRating /// A string describing the specified movie rating. public string GetRatingDescription(int rating) { - throw new NotImplementedException(); + switch (rating) + { + case 1: + return "Veľmi zlý"; + case 2: + return "Zlý"; + case 3: + return "Priemerný"; + case 4: + return "Dobrý"; + case 5: + return "Výborný"; + default: + return "Neplatné hodnotenie"; + }; + } -} \ No newline at end of file +} + diff --git a/tests/AppsLab-007-Casting.Tests/ConverterTests.cs b/tests/AppsLab-007-Casting.Tests/ConverterTests.cs index e9d8642c..e66c217b 100644 --- a/tests/AppsLab-007-Casting.Tests/ConverterTests.cs +++ b/tests/AppsLab-007-Casting.Tests/ConverterTests.cs @@ -1,68 +1,68 @@ -namespace AppsLab_007_Casting.Tests; +//namespace AppsLab_007_Casting.Tests; -public class ConverterTests -{ - private Converter converter; +//public class ConverterTests +//{ +// private Converter converter; - [SetUp] - public void Setup() - { - converter = new Converter(); - } +// [SetUp] +// public void Setup() +// { +// converter = new Converter(); +// } - [Test] - public void IntToDouble_Given7_ShouldReturn7Point0() - { - var result = converter.IntToDouble(7); - Assert.That(result, Is.EqualTo(7.0), "IntToDouble(7) should return 7.0"); - } +// [Test] +// public void IntToDouble_Given7_ShouldReturn7Point0() +// { +// var result = converter.IntToDouble(7); +// Assert.That(result, Is.EqualTo(7.0), "IntToDouble(7) should return 7.0"); +// } - [Test] - public void DoubleToInt_Given7Point8_ShouldReturn7() - { - var result = converter.DoubleToInt(7.8); - Assert.That(result, Is.EqualTo(7), "DoubleToInt(7.8) should return 7"); - } +// [Test] +// public void DoubleToInt_Given7Point8_ShouldReturn7() +// { +// var result = converter.DoubleToInt(7.8); +// Assert.That(result, Is.EqualTo(7), "DoubleToInt(7.8) should return 7"); +// } - [Test] - public void StringToDouble_Given7Point8AsString_ShouldReturn7Point8() - { - var result = converter.StringToDouble("7.8"); - Assert.That(result, Is.EqualTo(7.8), "StringToDouble(\"7.8\") should return 7.8"); - } +// [Test] +// public void StringToDouble_Given7Point8AsString_ShouldReturn7Point8() +// { +// var result = converter.StringToDouble("7.8"); +// Assert.That(result, Is.EqualTo(7.8), "StringToDouble(\"7.8\") should return 7.8"); +// } - [Test] - 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\""); - } +// [Test] +// 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\""); +// } - [Test] - public void IntToString_Given7_ShouldReturn7AsString() - { - var result = converter.IntToString(7); - Assert.That(result, Is.EqualTo("7"), "IntToString(7) should return \"7\""); - } +// [Test] +// public void IntToString_Given7_ShouldReturn7AsString() +// { +// var result = converter.IntToString(7); +// Assert.That(result, Is.EqualTo("7"), "IntToString(7) should return \"7\""); +// } - [Test] - public void StringToBool_GivenTrueAsString_ShouldReturnTrue() - { - var result = converter.StringToBool("true"); - Assert.That(result, Is.True, "StringToBool(\"true\") should return true"); - } +// [Test] +// public void StringToBool_GivenTrueAsString_ShouldReturnTrue() +// { +// var result = converter.StringToBool("true"); +// Assert.That(result, Is.True, "StringToBool(\"true\") should return true"); +// } - [Test] - public void BoolToString_GivenTrue_ShouldReturnTrueAsString() - { - var result = converter.BoolToString(true); - Assert.That(result, Is.EqualTo("True"), "BoolToString(true) should return \"True\""); - } +// [Test] +// public void BoolToString_GivenTrue_ShouldReturnTrueAsString() +// { +// var result = converter.BoolToString(true); +// Assert.That(result, Is.EqualTo("True"), "BoolToString(true) should return \"True\""); +// } - [Test] - public void BoolToString_GivenFalse_ShouldReturnFalseAsString() - { - var result = converter.BoolToString(false); - Assert.That(result, Is.EqualTo("False"), "BoolToString(false) should return \"False\""); - } -} +// [Test] +// public void BoolToString_GivenFalse_ShouldReturnFalseAsString() +// { +// var result = converter.BoolToString(false); +// Assert.That(result, Is.EqualTo("False"), "BoolToString(false) should return \"False\""); +// } +//}