Package Databases
Class InventoryRequestDatabase
java.lang.Object
Common.Database
Databases.InventoryRequestDatabase
The
InventoryRequestDatabase
class manages a collection of inventory requests.
It extends Database
and provides methods for creating, searching,
removing, and printing inventory requests.-
Field Summary
Fields inherited from class Common.Database
csvPath, headerFormat, records
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs anInventoryRequestDatabase
with a default CSV path.InventoryRequestDatabase
(String csvPath) Constructs anInventoryRequestDatabase
with a specified CSV path. -
Method Summary
Modifier and TypeMethodDescriptioncreateDatabaseItem
(String[] values) Creates a newInventoryRequest
instance from an array of values.void
Prints all items in the inventory request database.boolean
removeItem
(String medicine) Removes an inventory request by medicine name.boolean
removeItem
(String medicine, int request_value) Removes an inventory request by medicine name and request value.searchItem
(String medicine) Searches for an inventory request by medicine name.searchItem
(String medicine, int request_value) Searches for an inventory request by medicine name and request value.searchItems
(String medicine) Searches for all inventory requests associated with a specific medicine.Methods inherited from class Common.Database
addItem, extractFromCSV, getRecords, printItems, setcsvPath, setHeaderFormat, storeToCSV
-
Constructor Details
-
InventoryRequestDatabase
public InventoryRequestDatabase()Constructs anInventoryRequestDatabase
with a default CSV path. -
InventoryRequestDatabase
Constructs anInventoryRequestDatabase
with a specified CSV path.- Parameters:
csvPath
- the path to the CSV file containing inventory requests
-
-
Method Details
-
createDatabaseItem
Creates a newInventoryRequest
instance from an array of values.- Specified by:
createDatabaseItem
in classDatabase
- Parameters:
values
- an array of strings containing inventory request data- Returns:
- a new
InventoryRequest
object
-
printItems
public void printItems()Prints all items in the inventory request database.- Specified by:
printItems
in classDatabase
-
searchItem
Searches for an inventory request by medicine name.- Specified by:
searchItem
in classDatabase
- Parameters:
medicine
- the name of the medicine to search for- Returns:
- the found
Medicines
item; null if not found
-
searchItem
Searches for an inventory request by medicine name and request value.- Parameters:
medicine
- the name of the medicine to search forrequest_value
- the requested quantity of the medicine- Returns:
- the found
InventoryRequest
item; null if not found
-
searchItems
Searches for all inventory requests associated with a specific medicine.- Parameters:
medicine
- the name of the medicine to search for- Returns:
- a list of matching
InventoryRequest
objects; empty list if none found
-
removeItem
Removes an inventory request by medicine name.- Specified by:
removeItem
in classDatabase
- Parameters:
medicine
- the name of the medicine to remove from requests- Returns:
- true if any record was successfully removed; false otherwise
-
removeItem
Removes an inventory request by medicine name and request value.- Parameters:
medicine
- the name of the medicine to remove from requestsrequest_value
- the requested quantity to match for removal- Returns:
- true if any record was successfully removed; false otherwise
-