https://gist.github.com/anonymous/cbff9fc74258450eb27d50db6aa8ce03
I'm trying to write code to manage an inventory in a simple way.
This is the first code I've written to do this.
I'm having a bit of trouble understanding certain things. For context, this is intended to be a text adventure.
I have an Item class, and Weapons + First Aid subclasses. If I want to instantiate a weapon, I'll call Item sword = new Weapon("Sword") -- the Item class, as you'll see in my code, requires a name when it is instantiated.
If I want to find that Item in a room I'll pass "Sword" through to DeleteItemFromRoom(string item) and check the item string (containing "Sword") against the "name" property of the Item class to see if it exists.
I don't know if I'm doing it right, or if I should create a global manager, or if instead of creating new items for each room I had a table of pre-defined items and identified them by unique keys... I don't know how to do that though. So I was hoping for some advice or a nudge in the right direction. I want my code to be clean but I still want efficiency
↧