Package Controllers
Class InventoryManager
java.lang.Object
Controllers.InventoryManager
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 Summary
ConstructorsConstructorDescriptionInventoryManager
(InventoryDatabase inventoryDatabase) Constructs anInventoryManager
with the specified inventory database. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addMedicine
(String medicineName, int value, int alert) Adds a new medicine to the inventory.boolean
Adds stock to an existing medicine in the inventory.void
Displays all items in the current inventory.boolean
removeMedicine
(String medicineName) Removes a medicine from the inventory.boolean
removeStock
(String medicineName, int value) Removes a specified amount of stock from an existing medicine.boolean
updateAlertLine
(String medicineName, int value) Updates the alert level for low stock of an existing medicine.boolean
updateStock
(String medicineName, int value) Updates the stock level of an existing medicine.
-
Constructor Details
-
InventoryManager
Constructs anInventoryManager
with the specified inventory database.- Parameters:
inventoryDatabase
- theInventoryDatabase
used to manage medicine inventory
-
-
Method Details
-
addMedicine
Adds a new medicine to the inventory.- Parameters:
medicineName
- the name of the medicine to be addedvalue
- the initial stock quantity of the medicinealert
- the alert level for low stock- Returns:
- true if the medicine was added successfully; false if it already exists
-
removeMedicine
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
Adds stock to an existing medicine in the inventory.- Parameters:
medicineName
- the name of the medicine for which to add stockvalue
- the amount of stock to add- Returns:
- true if stock was added successfully; false if the medicine is not found
-
removeStock
Removes a specified amount of stock from an existing medicine.- Parameters:
medicineName
- the name of the medicine from which to remove stockvalue
- the amount of stock to remove- Returns:
- true if stock was removed successfully; false if the medicine is not found
-
updateStock
Updates the stock level of an existing medicine.- Parameters:
medicineName
- the name of the medicine whose stock is to be updatedvalue
- the new stock quantity for the medicine- Returns:
- true if the stock was updated successfully; false if not found
-
updateAlertLine
Updates the alert level for low stock of an existing medicine.- Parameters:
medicineName
- the name of the medicine whose alert level is to be updatedvalue
- 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.
-