Package Controllers

Class InventoryManager

java.lang.Object
Controllers.InventoryManager

public class InventoryManager extends Object
The InventoryManager class manages the inventory of medicines. It provides functionalities to add, remove, and update stock levels, as well as to display the current inventory.
  • Constructor Details

    • InventoryManager

      public InventoryManager(InventoryDatabase inventoryDatabase)
      Constructs an InventoryManager with the specified inventory database.
      Parameters:
      inventoryDatabase - the InventoryDatabase used to manage medicine inventory
  • Method Details

    • addMedicine

      public boolean addMedicine(String medicineName, int value, int alert)
      Adds a new medicine to the inventory.
      Parameters:
      medicineName - the name of the medicine to be added
      value - the initial stock quantity of the medicine
      alert - the alert level for low stock
      Returns:
      true if the medicine was added successfully; false if it already exists
    • removeMedicine

      public boolean removeMedicine(String medicineName)
      Removes a medicine from the inventory.
      Parameters:
      medicineName - the name of the medicine to be removed
      Returns:
      true if the medicine was removed successfully; false if not found
    • addStock

      public boolean addStock(String medicineName, int value)
      Adds stock to an existing medicine in the inventory.
      Parameters:
      medicineName - the name of the medicine for which to add stock
      value - the amount of stock to add
      Returns:
      true if stock was added successfully; false if the medicine is not found
    • removeStock

      public boolean removeStock(String medicineName, int value)
      Removes a specified amount of stock from an existing medicine.
      Parameters:
      medicineName - the name of the medicine from which to remove stock
      value - the amount of stock to remove
      Returns:
      true if stock was removed successfully; false if the medicine is not found
    • updateStock

      public boolean updateStock(String medicineName, int value)
      Updates the stock level of an existing medicine.
      Parameters:
      medicineName - the name of the medicine whose stock is to be updated
      value - the new stock quantity for the medicine
      Returns:
      true if the stock was updated successfully; false if not found
    • updateAlertLine

      public boolean updateAlertLine(String medicineName, int value)
      Updates the alert level for low stock of an existing medicine.
      Parameters:
      medicineName - the name of the medicine whose alert level is to be updated
      value - the new alert level for low stock
      Returns:
      true if the alert level was updated successfully; false if not found
    • displayInventory

      public void displayInventory()
      Displays all items in the current inventory.