Package Databases

Class InventoryDatabase

java.lang.Object
Common.Database
Databases.InventoryDatabase

public class InventoryDatabase extends Database
The InventoryDatabase class manages a collection of medicines in inventory. It extends Database and provides methods for creating, searching, removing, and printing inventory items.
  • Constructor Details

    • InventoryDatabase

      public InventoryDatabase()
      Constructs an InventoryDatabase with a default CSV path.
    • InventoryDatabase

      public InventoryDatabase(String csvPath)
      Constructs an InventoryDatabase with a specified CSV path.
      Parameters:
      csvPath - the path to the CSV file containing inventory data
  • Method Details

    • createDatabaseItem

      public DatabaseItems createDatabaseItem(String[] values)
      Creates a new Medicines instance from an array of values.
      Specified by:
      createDatabaseItem in class Database
      Parameters:
      values - an array of strings containing medicine data
      Returns:
      a new Medicines object
    • printItems

      public void printItems()
      Prints all items in the inventory database.
      Specified by:
      printItems in class Database
    • searchItem

      public DatabaseItems searchItem(String medicine_name)
      Searches for a medicine by its name.
      Specified by:
      searchItem in class Database
      Parameters:
      medicine_name - the name of the medicine to search for
      Returns:
      the found Medicines item; null if not found
    • removeItem

      public boolean removeItem(String medicine)
      Removes a medicine from the inventory by its name.
      Specified by:
      removeItem in class Database
      Parameters:
      medicine - the name of the medicine to remove from inventory
      Returns:
      true if any record was successfully removed; false otherwise