diff --git a/.vs/prog2-ss2020-wienkop/v16/.suo b/.vs/prog2-ss2020-wienkop/v16/.suo index 5cd28ad44c5029ba9710f829e8a3bfb0f0753717..f5ce652e1889bbb395e0513a908bea1582672633 100644 Binary files a/.vs/prog2-ss2020-wienkop/v16/.suo and b/.vs/prog2-ss2020-wienkop/v16/.suo differ diff --git a/02VerketteteListe-2/Program.cs b/02VerketteteListe-2/Program.cs index b734d9d128c44f802770a5c83881664dac7352ee..b31d3c8006804b30d45853cb9fb0fbe86de30cc0 100644 --- a/02VerketteteListe-2/Program.cs +++ b/02VerketteteListe-2/Program.cs @@ -280,7 +280,7 @@ namespace _02VerketteteListe_2 //l1.Print(); l1.AddBeforeNth(2, "Bodo"); l1.Print(); - foreach (string item in l1.Iterate(2)) + foreach (string item in l1.Filter("er")) { Console.WriteLine($"foreach: {item}"); } diff --git a/06GenericList/Liste.cs b/06GenericList/Liste.cs index a216acc785da316aeab7c85b93284c2327e626e8..6886b2086f3b3ff7cb1a3e2e534b133df17898c1 100644 --- a/06GenericList/Liste.cs +++ b/06GenericList/Liste.cs @@ -115,18 +115,19 @@ namespace _06GenericList // an der gespeicherten Pos. weitergemacht. } } - //public IEnumerable<T> Filter(string pattern) - //{ - // for (Element item = anf; item != null; item = item.next) - // { - // if (item.daten.Contains(pattern)) - // yield return item.daten; // Merken dieser Ausführungsposition - // // UND Zurückliefern von item.name - // // Beim nächsten Aufruf von GetEnumerator() wird - // // an der gespeicherten Pos. weitergemacht. - // } - //} - + public delegate bool MyFilter<V>(V daten); + public IEnumerable<T> Filter(MyFilter<T> myTest) // string => bool, x => x.Contains("er") + { + for (Element item = anf; item != null; item = item.next) + { + if (myTest(item.daten)) + yield return item.daten; // Merken dieser Ausführungsposition + // UND Zurückliefern von item.name + // Beim nächsten Aufruf von GetEnumerator() wird + // an der gespeicherten Pos. weitergemacht. + } + } + public void DeleteFirst() { // 1.Fall: Liste ist leer diff --git a/06GenericList/Program.cs b/06GenericList/Program.cs index dd435eae6f9b5f2788a6240abb136f331a9e896a..9bbc2673963110332c7a8316dd8355d98837024a 100644 --- a/06GenericList/Program.cs +++ b/06GenericList/Program.cs @@ -24,11 +24,27 @@ namespace _06GenericList Liste<int> il = new Liste<int>(); il.AddEnd(10); il.AddEnd(20); - il.Print(); + il.AddEnd(23); + il.AddEnd(21); + il.AddEnd(35); + il.AddEnd(40); + foreach (var item in il.Filter(x => x%2==0)) + { + Console.WriteLine(item); + } + //il.Print(); + Console.WriteLine("*****************"); Liste<string> sl = new Liste<string>(); sl.AddSorted("Emil"); sl.AddSorted("Anton"); + sl.AddSorted("Berta"); + sl.AddSorted("Dieter"); + foreach (var item in sl.Filter(x=>x.Contains("er"))) + { + Console.WriteLine(item); + } + Console.WriteLine("*****************"); sl.Print(); Liste<Person> pl = new Liste<Person>(); diff --git a/06GenericList/bin/Debug/netcoreapp3.1/06GenericList.dll b/06GenericList/bin/Debug/netcoreapp3.1/06GenericList.dll index 5c5c13bc3a09000d3da674a913832a0aa173f0e9..25473ed282428a4a8f59b3593c58121b55320ec1 100644 Binary files a/06GenericList/bin/Debug/netcoreapp3.1/06GenericList.dll and b/06GenericList/bin/Debug/netcoreapp3.1/06GenericList.dll differ diff --git a/06GenericList/bin/Debug/netcoreapp3.1/06GenericList.pdb b/06GenericList/bin/Debug/netcoreapp3.1/06GenericList.pdb index e5f3e7d62512c1d71b25313f5243fb9ec2851d18..5f7a2e3367d0464cb22873cb3a65c9de20559821 100644 Binary files a/06GenericList/bin/Debug/netcoreapp3.1/06GenericList.pdb and b/06GenericList/bin/Debug/netcoreapp3.1/06GenericList.pdb differ diff --git a/06GenericList/obj/Debug/netcoreapp3.1/06GenericList.dll b/06GenericList/obj/Debug/netcoreapp3.1/06GenericList.dll index 5c5c13bc3a09000d3da674a913832a0aa173f0e9..25473ed282428a4a8f59b3593c58121b55320ec1 100644 Binary files a/06GenericList/obj/Debug/netcoreapp3.1/06GenericList.dll and b/06GenericList/obj/Debug/netcoreapp3.1/06GenericList.dll differ diff --git a/06GenericList/obj/Debug/netcoreapp3.1/06GenericList.pdb b/06GenericList/obj/Debug/netcoreapp3.1/06GenericList.pdb index e5f3e7d62512c1d71b25313f5243fb9ec2851d18..5f7a2e3367d0464cb22873cb3a65c9de20559821 100644 Binary files a/06GenericList/obj/Debug/netcoreapp3.1/06GenericList.pdb and b/06GenericList/obj/Debug/netcoreapp3.1/06GenericList.pdb differ diff --git a/07 UebgSaKeyValueList/Program.cs b/07 UebgSaKeyValueList/Program.cs index 7ae5da3e6d4a3afcd868d92dd68e8d8b287bbfdb..916c978a965710d24768ecaafbf62963b7f168db 100644 --- a/07 UebgSaKeyValueList/Program.cs +++ b/07 UebgSaKeyValueList/Program.cs @@ -98,6 +98,7 @@ namespace _07KeyValueList terminverwaltung["03.06.2020"] = termineMi; terminverwaltung["02.06.2020"].Add(new Termin("11:30 Teams", "BayernMINT")); + // Pfannkuchen, Zutaten(Mehl, Milch, Eier), Zubereitung (Schritt1, Schritt2, ...) KeyValueListe<string, (List<string>, List<string>)> rezepte = new KeyValueListe<string, (List<string>, List<string>)>(); List<string> zutaten = new List<string>(); @@ -149,7 +150,7 @@ namespace _07KeyValueList KeyValueListe<(int, int), string> t4 = new KeyValueListe<(int, int), string>(); t4[(3, 6)] = "Kaffestunde"; - t4[(3, 5)] = "Vorlesung"; + t4[(2, 5)] = "Vorlesung"; KeyValueListe<ComplexKey, string> t5 = new KeyValueListe<ComplexKey, string>(); } diff --git a/07KeyValueList/KeyValueList.cs b/07KeyValueList/KeyValueList.cs index 2a50a2c492cd978de812d8221cb4f70f704d7ac4..bf9151ee0c87ba0169aa6b043427a3da30ffe1da 100644 --- a/07KeyValueList/KeyValueList.cs +++ b/07KeyValueList/KeyValueList.cs @@ -214,7 +214,6 @@ namespace _07KeyValueList //} - private Element ElementSearch(K key) { for (Element item = anf; item != null; item=item.next) diff --git a/08 UebgDiDatentypSet/Set.cs b/08 UebgDiDatentypSet/Set.cs index c8c4d9e4f1d624ec99eb45aa20d2b236df3bb7a3..c663330c640e3daf426e2acfc342128342bea917 100644 --- a/08 UebgDiDatentypSet/Set.cs +++ b/08 UebgDiDatentypSet/Set.cs @@ -6,8 +6,8 @@ namespace _08_UebgDiDatentypSet { interface ISet<T> { - public ISet<T> Intersect(ISet<T> set1, ISet<T> set2); - public ISet<T> Union(ISet<T> set1, ISet<T> set2); + public ISet<T> Intersect(ISet<T> set2); // Schnittmenge + public ISet<T> Union(ISet<T> set2); // Vereinigungsmenge public IEnumerable<T> GetEnumerator(); public bool Contains(T item); // true, wenn die Menge das Item bereits enthält public void Add(params T[] obj); @@ -16,7 +16,7 @@ namespace _08_UebgDiDatentypSet // Schreiben Sie eine Listenimplementierung des Datentyps Menge~Set, // welche das obige Interface implementiert - class ListSet<T> : ISet<T> + class ListSet<T> : ISet<T> where T:IComparable<T> { } } diff --git a/08DelegateIntro/Program.cs b/08DelegateIntro/Program.cs index 0726a9877cde90365f7341e34bf2ba325d4332ca..3772471901c9dfee4cad5788d89260789afd8669 100644 --- a/08DelegateIntro/Program.cs +++ b/08DelegateIntro/Program.cs @@ -4,19 +4,29 @@ namespace _08DelegateIntro { class Program { - static void Tabelle(double von, double bis) + // Firma-A hat dieses Programm erstellt + delegate double MyFunction(double x); + static void Wertetabelle(double von, double bis, MyFunction funktion) { - for (double x = von; x <= bis; x += (bis - von) / 5.0) - Console.WriteLine($"{x,6:f2} | {Math.Sin(x),10:f4}"); + for (double x = von; x <= bis; x += 1) + Console.WriteLine($"{x,6:f2} | {funktion(x),10:f4}"); Console.WriteLine("-------------------"); } - static double MeinQuadrieren(double x) + // funktion ist eine Variable, die eine Referenz auf eine Funktion übergeben bekommt + + // Firma-B möchte es verwenden UND MODIFIZIEREN + static double MeinQuadrieren(double xx) { - return x * x; + return xx * xx; } + static double ZweiX(double x) => 2 * x; static void Main(string[] args) { - Tabelle(1, 6); + Wertetabelle(1, 4, Math.Sin); + Wertetabelle(1, 3, MeinQuadrieren); + Wertetabelle(1, 3, ZweiX); + Wertetabelle(1, 3, delegate (double a) { return 3 * a; }); + Wertetabelle(1, 3, b => 4 * b); } } } diff --git a/08DelegateIntro/bin/Debug/netcoreapp3.1/08DelegateIntro.dll b/08DelegateIntro/bin/Debug/netcoreapp3.1/08DelegateIntro.dll index 62aa57e5a7889523003eae6bcb0af2439b4fdcf3..600155509fe489c2fb46438f6713e66466053efc 100644 Binary files a/08DelegateIntro/bin/Debug/netcoreapp3.1/08DelegateIntro.dll and b/08DelegateIntro/bin/Debug/netcoreapp3.1/08DelegateIntro.dll differ diff --git a/08DelegateIntro/bin/Debug/netcoreapp3.1/08DelegateIntro.pdb b/08DelegateIntro/bin/Debug/netcoreapp3.1/08DelegateIntro.pdb index 713413e8f56eeda8ea70261f9af91cd43ca3659f..4bf49a8869dae2ae95f703557916a4427caba9df 100644 Binary files a/08DelegateIntro/bin/Debug/netcoreapp3.1/08DelegateIntro.pdb and b/08DelegateIntro/bin/Debug/netcoreapp3.1/08DelegateIntro.pdb differ diff --git a/08DelegateIntro/obj/Debug/netcoreapp3.1/08DelegateIntro.csprojAssemblyReference.cache b/08DelegateIntro/obj/Debug/netcoreapp3.1/08DelegateIntro.csprojAssemblyReference.cache index 8a5ef041ae8402be96bf3fc66b33aedfc9a2f5c5..d7dd684443de8ada82f92a8e0cf14a64b9096fd6 100644 Binary files a/08DelegateIntro/obj/Debug/netcoreapp3.1/08DelegateIntro.csprojAssemblyReference.cache and b/08DelegateIntro/obj/Debug/netcoreapp3.1/08DelegateIntro.csprojAssemblyReference.cache differ diff --git a/08DelegateIntro/obj/Debug/netcoreapp3.1/08DelegateIntro.dll b/08DelegateIntro/obj/Debug/netcoreapp3.1/08DelegateIntro.dll index 62aa57e5a7889523003eae6bcb0af2439b4fdcf3..600155509fe489c2fb46438f6713e66466053efc 100644 Binary files a/08DelegateIntro/obj/Debug/netcoreapp3.1/08DelegateIntro.dll and b/08DelegateIntro/obj/Debug/netcoreapp3.1/08DelegateIntro.dll differ diff --git a/08DelegateIntro/obj/Debug/netcoreapp3.1/08DelegateIntro.pdb b/08DelegateIntro/obj/Debug/netcoreapp3.1/08DelegateIntro.pdb index 713413e8f56eeda8ea70261f9af91cd43ca3659f..4bf49a8869dae2ae95f703557916a4427caba9df 100644 Binary files a/08DelegateIntro/obj/Debug/netcoreapp3.1/08DelegateIntro.pdb and b/08DelegateIntro/obj/Debug/netcoreapp3.1/08DelegateIntro.pdb differ