Create an API to return generic items in Dictionary(C#)

Hi everybody,
I’m applying for a job at a game development company and they have assigned us a number of tests to determine whether we are suitable for the position…the first test is as follows:

Test 1: Game Item Database

  • Read in the provided comma delimited files, each row is a game item.

  • Create a base class for all items, then 2 derived classes based on the 2 files / item types (armour and weapons)

  • Using the item UID as the key, store all the items in a single dictionary.

  • Create an API to return generic items and also specific items of the derived classes. Retrieve by UID or by string search in the item name.

I am fine with everything up to and including “Using the item UID as the key, store all the items in a single dictionary”. I am assuming you define something like

Dictionary myContacts = new Dictionary();

then use the Add function to populate(correct me if I’m wrong). Where I am uncertain is the last point of creating an API. Can someone give me an idea of how to go about this?

Here you an example

It is an AssetBundleManager which use exactly the same thing - dictionary to provide references to assets using string keys.
API here are functions:




and each of them take as input the key: (url + version).ToString()

You can do the same, I guess. You need to get items from dictionary, create them and delete them. That would be a good API :slight_smile: Maybe not the best but a good one.

Also… could you send me by e-mail the rest of the tests? I am wondering :slight_smile:

ps: and one more thing. If my answer or anybody’s else answer will do with you, do not forget to mark it as “Accepted”. This would be much better than just thanks :slight_smile: So go then though all your posted question to do the same as well.