diff --git a/AppsLab.CSharp.Exercises.sln b/AppsLab.CSharp.Exercises.sln index 58bbf6b5..316a206f 100644 --- a/AppsLab.CSharp.Exercises.sln +++ b/AppsLab.CSharp.Exercises.sln @@ -93,10 +93,17 @@ 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}") = "bonusova uloha od maťa", "bonusova uloha od maťa\bonusova uloha od maťa.csproj", "{78C59A28-9A9D-4ED3-8D3B-357B35C1F4E3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "kalkulačka", "kalkulačka\kalkulačka.csproj", "{BF3EA235-B109-476E-ABD7-528CF84EA78C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "switch", "switch\switch.csproj", "{B192A910-9B33-4FEA-A7F3-CC12C10D7AF7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uloha hviezdicka", "uloha hviezdicka\uloha hviezdicka.csproj", "{90FE8A7B-2019-42BD-807A-5B8F12A95F56}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Boller", "witcher\Boller.csproj", "{98320FD6-CB60-4E2D-8F15-09EAB847DF3A}" +EndProject Global - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 @@ -226,18 +233,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 +629,69 @@ 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 + {78C59A28-9A9D-4ED3-8D3B-357B35C1F4E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {78C59A28-9A9D-4ED3-8D3B-357B35C1F4E3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {78C59A28-9A9D-4ED3-8D3B-357B35C1F4E3}.Debug|x64.ActiveCfg = Debug|Any CPU + {78C59A28-9A9D-4ED3-8D3B-357B35C1F4E3}.Debug|x64.Build.0 = Debug|Any CPU + {78C59A28-9A9D-4ED3-8D3B-357B35C1F4E3}.Debug|x86.ActiveCfg = Debug|Any CPU + {78C59A28-9A9D-4ED3-8D3B-357B35C1F4E3}.Debug|x86.Build.0 = Debug|Any CPU + {78C59A28-9A9D-4ED3-8D3B-357B35C1F4E3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {78C59A28-9A9D-4ED3-8D3B-357B35C1F4E3}.Release|Any CPU.Build.0 = Release|Any CPU + {78C59A28-9A9D-4ED3-8D3B-357B35C1F4E3}.Release|x64.ActiveCfg = Release|Any CPU + {78C59A28-9A9D-4ED3-8D3B-357B35C1F4E3}.Release|x64.Build.0 = Release|Any CPU + {78C59A28-9A9D-4ED3-8D3B-357B35C1F4E3}.Release|x86.ActiveCfg = Release|Any CPU + {78C59A28-9A9D-4ED3-8D3B-357B35C1F4E3}.Release|x86.Build.0 = Release|Any CPU + {BF3EA235-B109-476E-ABD7-528CF84EA78C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BF3EA235-B109-476E-ABD7-528CF84EA78C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BF3EA235-B109-476E-ABD7-528CF84EA78C}.Debug|x64.ActiveCfg = Debug|Any CPU + {BF3EA235-B109-476E-ABD7-528CF84EA78C}.Debug|x64.Build.0 = Debug|Any CPU + {BF3EA235-B109-476E-ABD7-528CF84EA78C}.Debug|x86.ActiveCfg = Debug|Any CPU + {BF3EA235-B109-476E-ABD7-528CF84EA78C}.Debug|x86.Build.0 = Debug|Any CPU + {BF3EA235-B109-476E-ABD7-528CF84EA78C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BF3EA235-B109-476E-ABD7-528CF84EA78C}.Release|Any CPU.Build.0 = Release|Any CPU + {BF3EA235-B109-476E-ABD7-528CF84EA78C}.Release|x64.ActiveCfg = Release|Any CPU + {BF3EA235-B109-476E-ABD7-528CF84EA78C}.Release|x64.Build.0 = Release|Any CPU + {BF3EA235-B109-476E-ABD7-528CF84EA78C}.Release|x86.ActiveCfg = Release|Any CPU + {BF3EA235-B109-476E-ABD7-528CF84EA78C}.Release|x86.Build.0 = Release|Any CPU + {B192A910-9B33-4FEA-A7F3-CC12C10D7AF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B192A910-9B33-4FEA-A7F3-CC12C10D7AF7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B192A910-9B33-4FEA-A7F3-CC12C10D7AF7}.Debug|x64.ActiveCfg = Debug|Any CPU + {B192A910-9B33-4FEA-A7F3-CC12C10D7AF7}.Debug|x64.Build.0 = Debug|Any CPU + {B192A910-9B33-4FEA-A7F3-CC12C10D7AF7}.Debug|x86.ActiveCfg = Debug|Any CPU + {B192A910-9B33-4FEA-A7F3-CC12C10D7AF7}.Debug|x86.Build.0 = Debug|Any CPU + {B192A910-9B33-4FEA-A7F3-CC12C10D7AF7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B192A910-9B33-4FEA-A7F3-CC12C10D7AF7}.Release|Any CPU.Build.0 = Release|Any CPU + {B192A910-9B33-4FEA-A7F3-CC12C10D7AF7}.Release|x64.ActiveCfg = Release|Any CPU + {B192A910-9B33-4FEA-A7F3-CC12C10D7AF7}.Release|x64.Build.0 = Release|Any CPU + {B192A910-9B33-4FEA-A7F3-CC12C10D7AF7}.Release|x86.ActiveCfg = Release|Any CPU + {B192A910-9B33-4FEA-A7F3-CC12C10D7AF7}.Release|x86.Build.0 = Release|Any CPU + {90FE8A7B-2019-42BD-807A-5B8F12A95F56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {90FE8A7B-2019-42BD-807A-5B8F12A95F56}.Debug|Any CPU.Build.0 = Debug|Any CPU + {90FE8A7B-2019-42BD-807A-5B8F12A95F56}.Debug|x64.ActiveCfg = Debug|Any CPU + {90FE8A7B-2019-42BD-807A-5B8F12A95F56}.Debug|x64.Build.0 = Debug|Any CPU + {90FE8A7B-2019-42BD-807A-5B8F12A95F56}.Debug|x86.ActiveCfg = Debug|Any CPU + {90FE8A7B-2019-42BD-807A-5B8F12A95F56}.Debug|x86.Build.0 = Debug|Any CPU + {90FE8A7B-2019-42BD-807A-5B8F12A95F56}.Release|Any CPU.ActiveCfg = Release|Any CPU + {90FE8A7B-2019-42BD-807A-5B8F12A95F56}.Release|Any CPU.Build.0 = Release|Any CPU + {90FE8A7B-2019-42BD-807A-5B8F12A95F56}.Release|x64.ActiveCfg = Release|Any CPU + {90FE8A7B-2019-42BD-807A-5B8F12A95F56}.Release|x64.Build.0 = Release|Any CPU + {90FE8A7B-2019-42BD-807A-5B8F12A95F56}.Release|x86.ActiveCfg = Release|Any CPU + {90FE8A7B-2019-42BD-807A-5B8F12A95F56}.Release|x86.Build.0 = Release|Any CPU + {98320FD6-CB60-4E2D-8F15-09EAB847DF3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {98320FD6-CB60-4E2D-8F15-09EAB847DF3A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {98320FD6-CB60-4E2D-8F15-09EAB847DF3A}.Debug|x64.ActiveCfg = Debug|Any CPU + {98320FD6-CB60-4E2D-8F15-09EAB847DF3A}.Debug|x64.Build.0 = Debug|Any CPU + {98320FD6-CB60-4E2D-8F15-09EAB847DF3A}.Debug|x86.ActiveCfg = Debug|Any CPU + {98320FD6-CB60-4E2D-8F15-09EAB847DF3A}.Debug|x86.Build.0 = Debug|Any CPU + {98320FD6-CB60-4E2D-8F15-09EAB847DF3A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {98320FD6-CB60-4E2D-8F15-09EAB847DF3A}.Release|Any CPU.Build.0 = Release|Any CPU + {98320FD6-CB60-4E2D-8F15-09EAB847DF3A}.Release|x64.ActiveCfg = Release|Any CPU + {98320FD6-CB60-4E2D-8F15-09EAB847DF3A}.Release|x64.Build.0 = Release|Any CPU + {98320FD6-CB60-4E2D-8F15-09EAB847DF3A}.Release|x86.ActiveCfg = Release|Any CPU + {98320FD6-CB60-4E2D-8F15-09EAB847DF3A}.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 +738,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 = {866F7F6F-A125-4546-B085-463906A14251} + EndGlobalSection EndGlobal diff --git "a/bonusova uloha od ma\305\245a/Program.cs" "b/bonusova uloha od ma\305\245a/Program.cs" new file mode 100644 index 00000000..7357069c --- /dev/null +++ "b/bonusova uloha od ma\305\245a/Program.cs" @@ -0,0 +1,155 @@ +//int a = 6; +//int b = 2; + +//int Sčítanie = a + b; +//int Odčítanie = a - b; +//int Násobenie = a * b; +//int Delenie = a / b; +//int Zvyšok = a % b; + +//bool Rovnosť = a == b; +//bool Nerovnosť = a != b; +//bool Väčšíako = a > b; +//bool Menšíako = a < b; +//bool Väčšíaleborovnýako = a >= b; +//bool Menšíaleborovnýako = a <= b; + + +//bool a = true; +//int b = 74; +//int c = 67; + +//bool andBool1 = a && (b > c); +//bool andBool2 = a && (b == c); +//bool andBool3 = a && (b == c) || (c < b); +//bool andBool4 = a && ((b == c) || (c < b)); + + +//bool a = true; +//int b = 20; +//int c = 15; +//bool d = false; +//int e = 20; + +//bool vysledok = ((c <= b) || !a) && (a == (e == b)); + +//bool vysledok2 = (!(a && d) || (!(b < e) && !vysledok)); + + +//int age = 21; +//if (age <= 18) +//{ +// Console.WriteLine("Som už veľký"); +// Console.WriteLine("Dám si veľké pivo"); +//} + +//string? input = Console.ReadLine(); +//int number = int.Parse(input); +//if (number >= 1 && number <= 6) +//{ +// Console.WriteLine("Hurá! mám kocku"); +//} +//else +//{ +// Console.WriteLine("Hej! Daj mi kocku!"); +//} + + +//string text = "querty"; +//text = "čauko"; +//text += ",koľko máš rokov?"; + +//int vek = int.Parse(Console.ReadLine()); + +//if (vek > 18) +//{ +// Console.WriteLine("Dám si veľké pivo"); +//} +//else if (vek <= 18) +//{ +// Console.WriteLine("Dám si malú kofolu"); +//} + + + + +//using System; +//using System.Collections.Generic; + +//class Program +//{ +// static void Main() +// { +// List numbers = new List(); +// string input; + +// Console.WriteLine("Zadávaj čísla. Ak chceš skončiť, zadaj '+'."); + +// while (true) +// { +// Console.Write("Zadaj číslo alebo '+': "); +// input = Console.ReadLine(); + +// if (input == "+") +// { +// break; +// } + +// if (double.TryParse(input, out double number)) +// { +// numbers.Add(number); +// } +// else +// { +// Console.WriteLine("Zadaj platné číslo alebo '+'."); +// } +// } + +// double sum = 0; +// foreach (double num in numbers) +// { +// sum += num; +// } + +// Console.WriteLine($"Súčet zadaných čísel je: {sum}"); +// } +//} + + + + +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; +} +Console.WriteLine($"Ahoj {meno}. Tvoj vek je {vek} rokov"); + + + + + + + + + + + + + + + + + diff --git "a/bonusova uloha od ma\305\245a/bonusova uloha od ma\305\245a.csproj" "b/bonusova uloha od ma\305\245a/bonusova uloha od ma\305\245a.csproj" new file mode 100644 index 00000000..902821a2 --- /dev/null +++ "b/bonusova uloha od ma\305\245a/bonusova uloha od ma\305\245a.csproj" @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + bonusova_uloha_od_maťa + enable + enable + + + diff --git "a/kalkula\304\215ka/Program.cs" "b/kalkula\304\215ka/Program.cs" new file mode 100644 index 00000000..730162fc --- /dev/null +++ "b/kalkula\304\215ka/Program.cs" @@ -0,0 +1,50 @@ +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 vysledok = operacia switch +{ + "+" => (cislo1 + cislo2), + "*" => (cislo1 * cislo2), + "/" => (cislo1 / cislo2), + "%" => (cislo1 % cislo2), +}; +Console.WriteLine($"Vysledok je: {vysledok}"); +Console.WriteLine("Stlac ENTER pre spustenie kalkulacky"); +Console.ReadLine(); +System.Environment.Exit(0); + + +//for (int i = 1; i <= 1000; i++) +//{ +// int modulo = i % 2; +// if (modulo == 0) +// { +// Console.WriteLine(i); +// } +//} + +//int[] numbers = new int[] { 10, 300, 20, 40, 50 }; +//string[] names = new string[] { "Janko", "Fero", "Miro", "Laco", "Palo" }; + +//string[,] matrix = new string[30, 5]; +//matrix[0, 2] = "Janko"; +//matrix[1, 2] = "Fero"; +//matrix[25, 4] = "Miro"; + +//for (int i = 0; i < 5; i++) +//{ +// for (int j = 0; j < 30; j++) +// { +// Console.Write(matrix[i, j] + ","); +// } +// Console.WriteLine(); +//} + + + + + diff --git "a/kalkula\304\215ka/kalkula\304\215ka.csproj" "b/kalkula\304\215ka/kalkula\304\215ka.csproj" new file mode 100644 index 00000000..2150e379 --- /dev/null +++ "b/kalkula\304\215ka/kalkula\304\215ka.csproj" @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/src/AppsLab-001-StartHere/Greetings.cs b/src/AppsLab-001-StartHere/Greetings.cs index fbe10953..f02fdb12 100644 --- a/src/AppsLab-001-StartHere/Greetings.cs +++ b/src/AppsLab-001-StartHere/Greetings.cs @@ -11,6 +11,6 @@ public class Greetings /// A string containing the greeting message. public string Hello() { - return "Hello World!"; + return "Hello AppsLab!"; } } diff --git a/src/AppsLab-002-ConsoleWriteLine/Program.cs b/src/AppsLab-002-ConsoleWriteLine/Program.cs index 837131c2..51ffd0e2 100644 --- a/src/AppsLab-002-ConsoleWriteLine/Program.cs +++ b/src/AppsLab-002-ConsoleWriteLine/Program.cs @@ -1 +1,7 @@ -Console.WriteLine("Hello, World!"); \ No newline at end of file +int age = 10; +string name = "george"; + +Console.WriteLine(age); +Console.WriteLine(name); + +Console.WriteLine($"My name is {name} and I am {age} years old."); \ No newline at end of file diff --git a/src/AppsLab-008-ConsoleReadLine/Program.cs b/src/AppsLab-008-ConsoleReadLine/Program.cs index 6f7376c9..24d14b0b 100644 --- a/src/AppsLab-008-ConsoleReadLine/Program.cs +++ b/src/AppsLab-008-ConsoleReadLine/Program.cs @@ -1,4 +1,5 @@ -Console.WriteLine("Ako sa voláš?"); +//ako sa voláš +Console.WriteLine("Ako sa voláš?"); string? meno = Console.ReadLine(); Console.WriteLine("Ahoj, " + meno); diff --git a/src/AppsLab-011-Strings/StringManipulator.cs b/src/AppsLab-011-Strings/StringManipulator.cs index f226d70d..9bfb5857 100644 --- a/src/AppsLab-011-Strings/StringManipulator.cs +++ b/src/AppsLab-011-Strings/StringManipulator.cs @@ -13,7 +13,7 @@ public class StringManipulator /// The concatenated string. public string AppendStrings(string first, string second) { - throw new NotImplementedException(); + return (first + second); } /// @@ -23,7 +23,7 @@ public string AppendStrings(string first, string second) /// The uppercase string. public string ConvertToUpper(string input) { - throw new NotImplementedException(); + return input.ToUpper(); } /// @@ -33,7 +33,7 @@ public string ConvertToUpper(string input) /// The lowercase string. public string ConvertToLower(string input) { - throw new NotImplementedException(); + return input.ToLower(); } /// @@ -44,7 +44,7 @@ public string ConvertToLower(string input) /// True if the substring is found, false otherwise. public bool ContainsSubstring(string input, string substring) { - throw new NotImplementedException(); + return input.Contains(substring); } /// @@ -55,6 +55,11 @@ 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.Trim(); } } \ No newline at end of file diff --git a/src/AppsLab-014-Switch/MovieRating.cs b/src/AppsLab-014-Switch/MovieRating.cs index ab689d49..774604be 100644 --- a/src/AppsLab-014-Switch/MovieRating.cs +++ b/src/AppsLab-014-Switch/MovieRating.cs @@ -10,8 +10,23 @@ public class MovieRating /// /// The movie rating to get a description for. /// A string describing the specified movie rating. - public string GetRatingDescription(int rating) + public static 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 "Vyborný"; + default: + return "Neplatné hodnotenie"; + } + } } \ No newline at end of file diff --git a/src/AppsLab-015-Arrays/ArrayProcessor.cs b/src/AppsLab-015-Arrays/ArrayProcessor.cs index 59f8d1c7..1041b255 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.Reflection.Metadata.Ecma335; + +namespace AppsLab_015_Arrays; /// /// Class ArrayProcessor provides methods for working with integer arrays. @@ -13,7 +15,11 @@ public class ArrayProcessor /// First element of the array, or 0 if array is empty. public int GetFirstElement(int[] numbers) { - throw new NotImplementedException(); + if (numbers is null || numbers.Length == 0) + { + return 0; + } + return numbers[0]; } /// @@ -24,7 +30,11 @@ public int GetFirstElement(int[] numbers) /// Last element of the array, or 0 if array is empty. public int GetLastElement(int[] numbers) { - throw new NotImplementedException(); + if (numbers is null || numbers.Length == 0) + { + return 0; + } + return numbers[numbers.Length - 1]; } /// @@ -36,7 +46,11 @@ public int GetLastElement(int[] numbers) /// Element at the specified position, or 0 if position is out of range. public int GetElementAtPosition(int[] numbers, int position) { - throw new NotImplementedException(); + if (numbers is null || numbers.Length == 0 || position >= numbers.Length) + { + return 0; + } + return numbers[position]; } /// @@ -46,6 +60,6 @@ public int GetElementAtPosition(int[] numbers, int position) /// Length of the array. public int GetLength(int[] numbers) { - throw new NotImplementedException(); + if (numbers is null) } } diff --git a/src/AppsLab-016-Loops/WeatherStats.cs b/src/AppsLab-016-Loops/WeatherStats.cs index 8bca9659..f90043f8 100644 --- a/src/AppsLab-016-Loops/WeatherStats.cs +++ b/src/AppsLab-016-Loops/WeatherStats.cs @@ -10,10 +10,8 @@ public class WeatherStats /// /// Array of temperatures. /// Average temperature. - public double AverageTemperature(double[] temperatures) - { - throw new NotImplementedException(); - } + public static double AverageTemperature(double[] temperatures); + /// /// Find the maximum temperature from the provided values. @@ -22,7 +20,15 @@ public double AverageTemperature(double[] temperatures) /// Maximum temperature. public double MaxTemperature(double[] temperatures) { - throw new NotImplementedException(); + double maximum = double .MaxValue; + foreach (double temperature in temperatures) + { + if (temperature < maximum) + { + maximum = temperature; + } + } + return maximum; } /// @@ -32,6 +38,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/switch/Program.cs b/switch/Program.cs new file mode 100644 index 00000000..2cc46ed9 --- /dev/null +++ b/switch/Program.cs @@ -0,0 +1,41 @@ +Console.WriteLine("Zadaj číslo od 1 do 7"); +//int DayOfWeek = int.Parse(Console.ReadLine()); + +//switch (DayOfWeek) +//{ +// case 1: +// Console.WriteLine("Pondelok"); +// break; +// case 2: +// Console.WriteLine("Utorok"); +// break; +// case 3: +// Console.WriteLine("Streda"); +// break; +// case 4: +// Console.WriteLine("Štvrtok"); +// break; +// case 5: +// Console.WriteLine("Piatok"); +// break; +// case 6: +// Console.WriteLine("Sobota"); +// break; +// case 7: +// Console.WriteLine("Nedeľa"); +// break; +// default: +// Console.WriteLine("Neplatný deň"); +// break; +//} + +int number = 3; + +string numberDescription = number switch +{ + 1 => "jeden", + 2 => "dva", + 3 => "tri", + _ => "neznáme číslo" +}; +Console.WriteLine(numberDescription); \ No newline at end of file diff --git a/switch/switch.csproj b/switch/switch.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/switch/switch.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/tests/AppsLab-014-Switch.Tests/MovieRatingTests.cs b/tests/AppsLab-014-Switch.Tests/MovieRatingTests.cs index bdd4adda..cae8d85b 100644 --- a/tests/AppsLab-014-Switch.Tests/MovieRatingTests.cs +++ b/tests/AppsLab-014-Switch.Tests/MovieRatingTests.cs @@ -13,42 +13,42 @@ public void Setup() [Test] public void GetRatingDescription_WithRating1_ReturnsVelmiZly() { - string description = _movieRating.GetRatingDescription(1); + string description = MovieRating.GetRatingDescription(1); Assert.That(description, Is.EqualTo("Veľmi zlý"), "Expected 'Veľmi zlý' for rating 1"); } [Test] - public void GetRatingDescription_WithRating2_ReturnsZly() + public void GetRatingDescriptionWithRating2ReturnsZlý() { - string description = _movieRating.GetRatingDescription(2); + string description = MovieRating.GetRatingDescription(2); Assert.That(description, Is.EqualTo("Zlý"), "Expected 'Zlý' for rating 2"); } [Test] public void GetRatingDescription_WithRating3_ReturnsPriemerny() { - string description = _movieRating.GetRatingDescription(3); + string description = MovieRating.GetRatingDescription(3); Assert.That(description, Is.EqualTo("Priemerný"), "Expected 'Priemerný' for rating 3"); } [Test] public void GetRatingDescription_WithRating4_ReturnsDobry() { - string description = _movieRating.GetRatingDescription(4); + string description = MovieRating.GetRatingDescription(4); Assert.That(description, Is.EqualTo("Dobrý"), "Expected 'Dobrý' for rating 4"); } [Test] - public void GetRatingDescription_WithRating5_ReturnsVyborny() + public void GetRatingDescriptionWithRating5ReturnsVyborný() { - string description = _movieRating.GetRatingDescription(5); + string description = MovieRating.GetRatingDescription(5); Assert.That(description, Is.EqualTo("Výborný"), "Expected 'Výborný' for rating 5"); } [Test] public void GetRatingDescription_WithInvalidRating_ReturnsInvalidRating() { - string description = _movieRating.GetRatingDescription(6); + string description = MovieRating.GetRatingDescription(6); Assert.That(description, Is.EqualTo("Neplatné hodnotenie"), "Expected 'Neplatné hodnotenie' for invalid rating"); } } \ No newline at end of file diff --git a/uloha hviezdicka/Program.cs b/uloha hviezdicka/Program.cs new file mode 100644 index 00000000..98cdd557 --- /dev/null +++ b/uloha hviezdicka/Program.cs @@ -0,0 +1,32 @@ +//string i = ("*"); +//Console.WriteLine(i); +//while (i.Length < 5) +//{ +// i = (i + "*"); +// Console.WriteLine(i); +//} + +//i = ("**"); +//Console.WriteLine(i); +//while (i.Length < 5) +//{ +// i = (i + "*"); +// Console.WriteLine(i); +//} + + + + +//int[] numbers = new int[] { 11, 50, 48, 49, 6, 5, 7, 1, 11, 18 }; +//int vysledok = 0; +//for (int i = 0; i < numbers.Length; i++) +//{ +// vysledok += numbers[i]; +//} +//Console.WriteLine(vysledok); + +string[] veta = { "Dnes sa mám dobre" }; +foreach (var v in veta) +{ + Console.WriteLine(v); +} \ No newline at end of file diff --git a/uloha hviezdicka/uloha hviezdicka.csproj b/uloha hviezdicka/uloha hviezdicka.csproj new file mode 100644 index 00000000..929856f2 --- /dev/null +++ b/uloha hviezdicka/uloha hviezdicka.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + uloha_hviezdicka + enable + enable + + + diff --git a/witcher/Boller.csproj b/witcher/Boller.csproj new file mode 100644 index 00000000..2150e379 --- /dev/null +++ b/witcher/Boller.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/witcher/Program.cs b/witcher/Program.cs new file mode 100644 index 00000000..8d006d8b --- /dev/null +++ b/witcher/Program.cs @@ -0,0 +1,65 @@ + +int HPBoller = 100; +int DMGBoller = 20; +int HPZombie = 100; +int DMGZombie = 10; //pridal som HP aj DMG Zobiemu aj Bollerovi + +Console.WriteLine("START GAME"); +Console.WriteLine("tvoj pocet zivotov je " + HPBoller + " a tvoj pocet damege je " + DMGBoller); +Console.WriteLine("prisera oproti tebe ma " + HPZombie + " zivotov a " + DMGZombie + " damage"); +Console.WriteLine("tvoja postava sa vola BOLLER a ak si ready tak sa môzes pustit do prveho suboja"); +Console.WriteLine("si ready?"); +Console.ReadLine(); + +Console.WriteLine("dobre tak ked si ready tak podme na to"); +Console.WriteLine("PRVE KOLO"); +Console.WriteLine("oproti tebe stoji zombie"); +Console.WriteLine("das mu uder na hlavu ci do brucha"); +Console.ReadLine(); +if (Console.ReadLine() == brucho) +{ + Console.WriteLine("zombiemu si vyhazil dych"); + Console.WriteLine("rana do brucha mu spôsobila " + DMGBoller + " poskodenia"); +} +else if (Console.ReadLine() == hlava) +{ + Console.WriteLine("zombiemu skoro odpadla hlava"); + Console.WriteLine("uder na hlavu mu spôsobilo " + DMGBoller + " Damage"); +} + +Console.WriteLine("pozor!Caka ta uder od zombie"); +Console.WriteLine("rychlo kry sa!"); +Console.WriteLine("nestihol si dostal si bolestivi uder na spanok bude ta to stat 10HP"); +Console.WriteLine("neboj sa mozno budes mat vacsie stastie v dialsom kole"); + +Console.WriteLine("DRUHE KOLO"); +Console.WriteLine("dobre zacalo druhe kolo a ty sa mozes rozhodnut ze ci ho zastrelis so zbranou alebo ho prepychnes nozom"); +Console.ReadLine(); +if (Console.ReadLine() == zbran) +{ + Console.WriteLine("skvele zasiahol si ho zbranov dal si mu 50HP dole"); +} +else if (Console.ReadLine() == nozik) +{ + Console.WriteLine("prepychol si mu rebra dal si mu 35HP dole"); +} +Console.WriteLine("ooooo bacha zombie vytahuje teleskop"); +Console.WriteLine("dostal si silny uder teleskopom to ta bude stat 40HP dole"); + +Console.WriteLine("TRETIE KOLO"); +Console.WriteLine("tvoje moznosti su vytiahnut boxer,chytit ho do kravaty alebo mu dat tornado high kick"); +Console.ReadLine(); +if (Console.WriteLine() == boxer) +{ + Console.WriteLine("udrel si na bradu,dal si mu 15HP dole"); +} +else if (Console.ReadLine() == kravata) +{ + Console.WriteLine("chytil si ho do kravaty ale on sa rychlo z nej dostal,nedal si mu ziadne poskodenie"); +} +else if (Console.ReadLine() == tornadohighkick) +{ + Console.WriteLine("zombie spadol na zem a skoro ho vyplo,dal si mu 30HP dole"); +} +Console.WriteLine("ale zombie ti dal bombu do brucha a nasledne high kick na bradu"); +Console.WriteLine("je mi to luto ale zombie ta vypol");