Package Databases
Class InventoryDatabase
java.lang.Object
Common.Database
Databases.InventoryDatabase
The
InventoryDatabase
class manages a collection of medicines in inventory.
It extends Database
and provides methods for creating, searching,
removing, and printing inventory items.-
Field Summary
Fields inherited from class Common.Database
csvPath, headerFormat, records
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs anInventoryDatabase
with a default CSV path.InventoryDatabase
(String csvPath) Constructs anInventoryDatabase
with a specified CSV path. -
Method Summary
Modifier and TypeMethodDescriptioncreateDatabaseItem
(String[] values) Creates a newMedicines
instance from an array of values.void
Prints all items in the inventory database.boolean
removeItem
(String medicine) Removes a medicine from the inventory by its name.searchItem
(String medicine_name) Searches for a medicine by its name.Methods inherited from class Common.Database
addItem, extractFromCSV, getRecords, printItems, setcsvPath, setHeaderFormat, storeToCSV
-
Constructor Details
-
InventoryDatabase
public InventoryDatabase()Constructs anInventoryDatabase
with a default CSV path. -
InventoryDatabase
Constructs anInventoryDatabase
with a specified CSV path.- Parameters:
csvPath
- the path to the CSV file containing inventory data
-
-
Method Details
-
createDatabaseItem
Creates a newMedicines
instance from an array of values.- Specified by:
createDatabaseItem
in classDatabase
- 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 classDatabase
-
searchItem
Searches for a medicine by its name.- Specified by:
searchItem
in classDatabase
- Parameters:
medicine_name
- the name of the medicine to search for- Returns:
- the found
Medicines
item; null if not found
-
removeItem
Removes a medicine from the inventory by its name.- Specified by:
removeItem
in classDatabase
- Parameters:
medicine
- the name of the medicine to remove from inventory- Returns:
- true if any record was successfully removed; false otherwise
-