Figure 10.
This function could be optimized by checking whether specific Key is given (Bottle_2 and not only Bottle). Therefore, if the specific Key is given, only required check before the retrieval is to check if that Key exists in the dictionary at all. Our specific implementation required that special objects would be given to player to hold right after they are taken out from the backpack. For example, it was required that player drinks water after water bottle is taken out. In this case specific Key is give to the function, and retrieved object was sent to the Player class HoldObject(gameObject) function.