I am working on an inventory system for a text based RPG. I need to be able to have a max inventory size, add items, remove items, and allow some items to be stacked (and by extension, a way to determine if an item can be stacked, or if it needs to go into a new inventory slot). I have two main questions for this posting. The first deals with my design choice, and the second about a specific problem I am having.
First, my design choice. I have two classes I am using (below), an Item class and an InventoryItem class. Item is going to be a base class that all items in the game will extend. InventoryItem is the actual inventory system. I have started out by creating an array of Items and initializing the array to  which is the current inventory size we are using. I have added methods to show the current inventory, and to add and remove items. My question is whether or not an array should be used or if I should look into list or collections more. I know this is a very general question, but I am hoping for someone with more experience to let me know if this way is feasible, or if it may be better to attempt another way.
Second, I am having some trouble with if/else. In the InventoryItem class, inside the method addItem, I am using an if/else block. The first if statement checks to see if the item being passed in is stackable. If the item is stackable, then code to add the item to the stack. ELSE, just find the next empty spot and add the item. This else block doesn't execute and I am having trouble figuring out why. My expectation of my code is: If the item is stackable, try and stack it, if it can't be stacked, just add it to an empty slot (if available), OR If the item is not stackable, just add it to the next empty spot (if available).
Thank you in advance for any help!
The two people in this world are those that do, and those that don't.
I have changed my code to use if(item.stackable) as opposed to if(item.stackable==true) and I can now get my Else block to execute. I am having some trouble getting the statements after I check item.stackable to execute, but I want to try a few things before I post back about that as I think I should be able to accomplish what I need from here.....hopefully lol.