Alright so this is what I have so far. The items are going to need more parameters eventually, but I'll handle them with strings and integers in the constructor of each item.
HashMap<String, Item> ItemList();
private static void Hoe(){
Item hoe = new Item();
hoe.itemName = "hoe";
ItemList.put(hoe.itemName, hoe);
}
Each of my item constructors will look like this, and then I populate the HashMap by calling the static method at the start of the game.
putItem(Item.ItemList.get("seed"), 2);
public void putItem(Item item, int itemQuantity){
for(int i = 0; i < playerInventory.length; i++){
if(playerInventory[i].itemName == item.itemName){
playerInventory[i].itemQuantity += itemQuantity;
break;
}
else if(playerInventory[i].itemName == "empty") {
playerInventory[i] = item;
playerInventory[i].itemQuantity += itemQuantity;
item.itemIndexInInventory = i;
break;
}
}
}
This is how I add the item to my inventory. It works right now but as I add more parameters like different seed types and strength of tools, I'm sure ill need to change some things.