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!:
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. 😛