Recreating a Dictionary

Updated on December 24, 2017 in [C] Intermediate
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
1 on July 8, 2016

I have two versions for that challenge, one is intermediate to advanced (closer to intermediate, though), and the other is for beginners. I just want to specify: Beginner is not someone who just started learning and his knowledge ends when it comes to more than methods. I am talking about someone that has finished something like Brackeys’ course, maybe a LITTLE bit more. So Console.WriteLine people, you do better learn some more before trying this. 😉

INTERMEDIATE:
You have to recreate the dictionary, from the System.Collection.Generic namespace, which contains the following methods:
Add (an overload with a KeyValuePair and an overload with a key and a value)
Remove (overloads like the previous one)
Clear
Contains
(one overload with a KeyValuePair, and one with a key)
MoveTo
CopyTo

You can rename all of those methods, of course, but make sure the meaning stays the same. I won’t give you any more information about that, you should know how to do it yourself. I will just give you one hint.
Hint: Use interfaces.
The test you should do is to make an instance, add some variables with the Add method, and then use a foreach loop to print them all. Be creative with the tests for the other methods. As an example, here is the test I did:


OverridenDictionary<int, string> thingsILike = new OverridenDictionary<int, string>();

thingsILike.Add(0, "I love food");

thingsILike.Add(1, "I kinda like sports");

thingsILike.Add(2, "I like programming");

thingsILike.Add(3, "I enjoy playing video games");
foreach(KeyValuePair<int, string> thingILike in thingsILike)

Console.WriteLine(thingILike);
Console.ReadLine();


I myself still didn’t make the other methods, but I already have the ideas of how to make them in my mind, so it shouldn’t be a problem.

BEGINNER:
Just like the intermediate, you should recreate the dictionary, but with less methods and you will get many more hints. Here are the methods:
Add (same overloads as the intermediate)
Remove (same as previously)
Clear

The people doing the intermediate might not wanna see those hints, so here they are, Beginners!:

Click to Expand

Let’s hope this isn’t gonna be like the previous challenge I made, and more people would enter. 😛 I actually feel like more people would joint this one… It’s better…
Well, good luck, if you will try. 😛

  • Liked by
  • maxartz15
  • Dion Dokter
  • Fabi
  • HunGARE
Reply
0 on December 24, 2017

wait.. was “MoveTo” and “CopyTo” deprecated? I looked up the documentation for dictionaries to get a better idea into what those methods do and they weren’t listed in the methods list, or on the page at all for that mater. (this is the link to the documentation am referencing: https://msdn.microsoft.com/en-us/library/xfhwa508(v=vs.110).aspx)

  • Liked by
Reply
Cancel