diff --git a/Exercises/E12_ResizeArrays/Exercise_1.cs b/Exercises/E12_ResizeArrays/Exercise_1.cs new file mode 100644 index 0000000..eaa33bb --- /dev/null +++ b/Exercises/E12_ResizeArrays/Exercise_1.cs @@ -0,0 +1,23 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Data.Common; + +namespace Exercises_C_Sharp.E12_ResizeArray +{ + class Exercise_1 + { + public static void Start() + { + int[] arr = [13, 34, 234, 12, 345, 34]; + + //Fügen Sie dem oberen Array die Zahl 155 hinzu: + //Code START + + //Code ENDE + + for(int i = 0; i < arr.Length; i++) + Console.Write(arr[i] + " - "); + } + } +} \ No newline at end of file diff --git a/Exercises/E12_ResizeArrays/Exercise_2.cs b/Exercises/E12_ResizeArrays/Exercise_2.cs new file mode 100644 index 0000000..2908e08 --- /dev/null +++ b/Exercises/E12_ResizeArrays/Exercise_2.cs @@ -0,0 +1,27 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Data.Common; + +namespace Exercises_C_Sharp.E12_ResizeArray +{ + class Exercise_2 + { + public static void Start() + { + Random rand = new(); + int random = rand.Next(5,20); + int[] arr = new int[random]; + for(int i = 0; i < random; i++) + arr[i] = rand.Next(1,1000); + + //Oben wir ein zufälliges Array erstellt. Sorgen Sie dafür, dass den Array eine zufällige Zahl hinzugefügt wird: + //Code START + + //Code ENDE + + for(int i = 0; i < arr.Length; i++) + Console.Write(arr[i] + " - "); + } + } +} \ No newline at end of file diff --git a/Exercises/E12_ResizeArrays/Exercise_3.cs b/Exercises/E12_ResizeArrays/Exercise_3.cs new file mode 100644 index 0000000..eb0a0b8 --- /dev/null +++ b/Exercises/E12_ResizeArrays/Exercise_3.cs @@ -0,0 +1,27 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Data.Common; + +namespace Exercises_C_Sharp.E12_ResizeArray +{ + class Exercise_3 + { + public static void Start() + { + string[] userinputs = []; + //Lassen Sie den User 3 String eingeben. Diese sollen in das obere Array hineingeschrieben werden. + + for(int i = 0; i < 3; i++) + { + //Code START + + //Code ENDE + } + + Console.Clear(); + for(int i = 0; i < userinputs.Length; i++) + Console.WriteLine(userinputs[i]); + } + } +} \ No newline at end of file diff --git a/Exercises/E12_ResizeArrays/dummy.txt b/Exercises/E12_ResizeArrays/dummy.txt deleted file mode 100644 index e69de29..0000000 diff --git a/Exercises/E13_Foreach/Exercise_1.cs b/Exercises/E13_Foreach/Exercise_1.cs new file mode 100644 index 0000000..b8be1ed --- /dev/null +++ b/Exercises/E13_Foreach/Exercise_1.cs @@ -0,0 +1,20 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Data.Common; +using System.Dynamic; + +namespace Exercises_C_Sharp.E1_Foreach +{ + class Exercise_1 + { + public static void Start() + { + int[] arr = [1, 2, 3, 4]; + //Geben Sie mit Hilfe einer Foreach-Schleife die Zahlen in dem oberen Array aus: + //Code START + Console.WriteLine(arr); + //Code ENDE + } + } +} \ No newline at end of file diff --git a/Exercises/E13_Foreach/Exercise_2.cs b/Exercises/E13_Foreach/Exercise_2.cs new file mode 100644 index 0000000..84bd32c --- /dev/null +++ b/Exercises/E13_Foreach/Exercise_2.cs @@ -0,0 +1,19 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Data.Common; + +namespace Exercises_C_Sharp.E1_Foreach +{ + class Exercise_2 + { + public static void Start() + { + int[] arr = [23, 45, 24, 56, 34, 56, 23, 56, 23, 5]; + //Addieren Sie alle Werte in dem Array mit einer Foreach-Schleife und geben Sie das Ergebnis aus: + //Code START + Console.WriteLine(arr); + //Code ENDE + } + } +} \ No newline at end of file diff --git a/Exercises/E13_Foreach/Exercise_3.cs b/Exercises/E13_Foreach/Exercise_3.cs new file mode 100644 index 0000000..62285ac --- /dev/null +++ b/Exercises/E13_Foreach/Exercise_3.cs @@ -0,0 +1,19 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Data.Common; + +namespace Exercises_C_Sharp.E1_Foreach +{ + class Exercise_3 + { + public static void Start() + { + int[] arr = [13, 45, 23, 45, 23, 5, 7, 44, 72, 30, 22, 46]; + //Addieren Sie alle geraden Werte und subtrahieren Sie alle ungeraden Werte in einer Foreach-Schleife. Geben Sie dann das Ergebnis auf der Konsole aus: + //Code START + Console.WriteLine(arr); + //Code ENDE + } + } +} \ No newline at end of file diff --git a/Exercises/E13_Foreach/Exercise_4.cs b/Exercises/E13_Foreach/Exercise_4.cs new file mode 100644 index 0000000..211e239 --- /dev/null +++ b/Exercises/E13_Foreach/Exercise_4.cs @@ -0,0 +1,19 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Data.Common; + +namespace Exercises_C_Sharp.E1_Foreach +{ + class Exercise_4 + { + public static void Start() + { + string[] arr = ["Dies", "ist", "ein", "wunderbarer", "Satz"]; + //Geben Sie den Satz, dessen Wörter in dem Array oben gespeichert sind, sauber mit Hilfe einer Foreach-Schleife auf der Konsole aus: + //Code START + Console.WriteLine(arr); + //Code ENDE + } + } +} \ No newline at end of file diff --git a/Exercises/E13_Foreach/Exercise_5.cs b/Exercises/E13_Foreach/Exercise_5.cs new file mode 100644 index 0000000..ad591cd --- /dev/null +++ b/Exercises/E13_Foreach/Exercise_5.cs @@ -0,0 +1,25 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Data.Common; + +namespace Exercises_C_Sharp.E1_Foreach +{ + class Exercise_5 + { + public static void Start() + { + //Lassen Sie den User einen String eingeben: + //Code START + + //Code ENDE + + Console.Clear(); + + //Geben Sie jeden einzelnen Buchstaben der Eingabedes Users jeweils in einer eigenen Zeile auf der Konsole aus: + //Code START + + //Code ENDE + } + } +} \ No newline at end of file diff --git a/Exercises/E13_Foreach/Exercise_6.cs b/Exercises/E13_Foreach/Exercise_6.cs new file mode 100644 index 0000000..580e745 --- /dev/null +++ b/Exercises/E13_Foreach/Exercise_6.cs @@ -0,0 +1,19 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Data.Common; + +namespace Exercises_C_Sharp.E1_Foreach +{ + class Exercise_6 + { + public static void Start() + { + string[] arr = ["Es", "ist", "ein", "wunderschöner", "Morgen"]; + //Geben Sie jeden einzelnen Buchstaben des Arrays oben auf der Konsole in jeweils einer eigenen Zeile aus: + //Code START + Console.WriteLine(arr); + //Code ENDE + } + } +} \ No newline at end of file diff --git a/Exercises/E13_Foreach/dummy.txt b/Exercises/E13_Foreach/dummy.txt deleted file mode 100644 index e69de29..0000000 diff --git a/Exercises/E14_While/Exercise_1.cs b/Exercises/E14_While/Exercise_1.cs new file mode 100644 index 0000000..fd3b0dd --- /dev/null +++ b/Exercises/E14_While/Exercise_1.cs @@ -0,0 +1,24 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Data.Common; +using System.Dynamic; + +namespace Exercises_C_Sharp.E14_While +{ + class Exercise_1 + { + public static void Start() + { + //Lassen Sie den User einen Integer eingeben: + //Code START + + //Code ENDE + + //Geben Sie mit Hilfe der While-Schleife alle Wert von der Zahl bis 0 aus: + //Code START + + //Code ENDE + } + } +} \ No newline at end of file diff --git a/Exercises/E14_While/dummy.txt b/Exercises/E14_While/dummy.txt deleted file mode 100644 index e69de29..0000000 diff --git a/Program.cs b/Program.cs index f7709d7..ab01b4c 100644 --- a/Program.cs +++ b/Program.cs @@ -219,26 +219,31 @@ namespace Exercises_C_Sharp ] }; //************************ - //******Resize Array****** TODO + //******Resize Array****** //************************ ExerciseGroup resizeArrayElements = new() { Name = "12. Resize Array", - ElementList = new() - { - new(){Name = "Übung 1", Method = E18_Methods.Exercise_1.Start} - } + ElementList = [ + new(){Name = "Übung 1", Method = E12_ResizeArray.Exercise_1.Start}, + new(){Name = "Übung 2", Method = E12_ResizeArray.Exercise_2.Start}, + new(){Name = "Übung 3", Method = E12_ResizeArray.Exercise_3.Start} + ] }; //************************ - //*******FOREACH******* TODO + //*******FOREACH********** //************************ ExerciseGroup foreachElements = new() { Name = "13. foreach", - ElementList = new() - { - new(){Name = "Übung 1", Method = E18_Methods.Exercise_1.Start} - } + ElementList = [ + new(){Name = "Übung 1", Method = E1_Foreach.Exercise_1.Start}, + new(){Name = "Übung 2", Method = E1_Foreach.Exercise_2.Start}, + new(){Name = "Übung 3", Method = E1_Foreach.Exercise_3.Start}, + new(){Name = "Übung 4", Method = E1_Foreach.Exercise_4.Start}, + new(){Name = "Übung 5", Method = E1_Foreach.Exercise_5.Start}, + new(){Name = "Übung 6", Method = E1_Foreach.Exercise_6.Start} + ] }; //************************ //**********WHILE********* TODO