From 0b03c0124b3f8d1a56db003d6382e1c5143fd5c9 Mon Sep 17 00:00:00 2001 From: Tonnes Date: Mon, 27 Jan 2025 14:05:25 +0100 Subject: [PATCH] Done --- csharp-fundamentals-maps.Main/Core.cs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/csharp-fundamentals-maps.Main/Core.cs b/csharp-fundamentals-maps.Main/Core.cs index 8f4d84a..6fbae52 100644 --- a/csharp-fundamentals-maps.Main/Core.cs +++ b/csharp-fundamentals-maps.Main/Core.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -48,11 +49,8 @@ in the createPerson method public string getValue(string key) { - - - return string.Empty; - - + Dictionary person = createPerson(); + return person[key]; } //TODO: 2. Modify below method named hasKey that accepts two parameters: @@ -64,6 +62,10 @@ in the provided dictionary */ public bool hasKey(Dictionary dictionary, string isitthere) { + if (dictionary.ContainsKey(isitthere)) + { + return true; + } return false; } @@ -78,8 +80,11 @@ public bool hasKey(Dictionary dictionary, string isitthere) */ public int getValueOrDefault(Dictionary dictionary, string isitthere) { - return 0; - + if (dictionary.ContainsKey(isitthere)) + { + return dictionary[isitthere]; + } + return -1; } @@ -104,9 +109,10 @@ public List buildSecretPhrase(int[] numbers) map.Add(7, "muse"); map.Add(96, "nice"); // Write your code below this comment... - - - + foreach (int element in numbers) + { + results.Add(map[element]); + } // // ...and above this comment return results; }