package org.project.inventory;

import org.project.item.Item;

import java.util.ArrayList;

public class Inventory {

    private ArrayList<Item> items;

    public Inventory() {
        items = new ArrayList<>();
    }

    public void addItem(Item item) {

        items.add(item);

        System.out.println(item.getName() + " added to inventory.");
    }

    public void removeItem(Item item) {
        items.remove(item);
    }

    public ArrayList<Item> getItems() {
        return items;
    }

    public void showInventory() {

        if(items.isEmpty()) {
            System.out.println("Inventory is empty.");
            return;
        }

        System.out.println("=== Inventory ===");

        for(int i = 0; i < items.size(); i++) {

            System.out.println(
                    (i + 1) + ". " + items.get(i).getName()
            );
        }
    }
}
