Package DatabaseItems
Class Medicines
java.lang.Object
DatabaseItems.Medicines
- All Implemented Interfaces:
DatabaseItems
The
Medicines
class represents a medicine item in the inventory.
It implements the DatabaseItems
interface and provides methods
for serialization, deserialization, and displaying medicine details.-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aMedicines
instance with specified medicine name.Constructs aMedicines
instance by deserializing from an array of parameters.Constructs aMedicines
instance with specified medicine name, stock level, and alert level. -
Method Summary
Modifier and TypeMethodDescriptionvoid
deserialise
(String... params) Deserializes parameters into aMedicines
object.int
Returns the alert level for low stock.Returns the name of the medicine.int
getStock()
Returns the current stock level of the medicine.void
Prints details of the medicine item to the console.Serializes theMedicines
object into a CSV format string.void
setAlertLevel
(int alert_level) Sets a new alert level for low stock.void
setMedicine
(String medicine) Sets a new name for the medicine.void
setStock
(int stock) Sets a new stock level for the medicine.
-
Constructor Details
-
Medicines
Constructs aMedicines
instance with specified medicine name.- Parameters:
medicine
- the name of the medicine
-
Medicines
Constructs aMedicines
instance with specified medicine name, stock level, and alert level.- Parameters:
medicine
- the name of the medicinestock
- the initial stock level of the medicinealert_level
- the alert level for low stock
-
Medicines
Constructs aMedicines
instance by deserializing from an array of parameters.- Parameters:
params
- an array of strings containing serialized data for the medicine
-
-
Method Details
-
deserialise
Deserializes parameters into aMedicines
object.- Specified by:
deserialise
in interfaceDatabaseItems
- Parameters:
params
- an array of strings containing serialized data for the medicine
-
serialise
Serializes theMedicines
object into a CSV format string.- Specified by:
serialise
in interfaceDatabaseItems
- Returns:
- a string representing the serialized data of the medicine
-
printItem
public void printItem()Prints details of the medicine item to the console.- Specified by:
printItem
in interfaceDatabaseItems
-
getMedicine
Returns the name of the medicine.- Returns:
- the name of the medicine
-
getStock
public int getStock()Returns the current stock level of the medicine.- Returns:
- the current stock level
-
getAlertLevel
public int getAlertLevel()Returns the alert level for low stock.- Returns:
- the alert level for low stock
-
setMedicine
Sets a new name for the medicine.- Parameters:
medicine
- the new name of the medicine
-
setStock
public void setStock(int stock) Sets a new stock level for the medicine.- Parameters:
stock
- the new stock level of the medicine
-
setAlertLevel
public void setAlertLevel(int alert_level) Sets a new alert level for low stock.- Parameters:
alert_level
- the new alert level for low stock
-