Package DatabaseItems

Class Medicines

java.lang.Object
DatabaseItems.Medicines
All Implemented Interfaces:
DatabaseItems

public class Medicines extends Object implements 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

    Constructors
    Constructor
    Description
    Medicines(String medicine)
    Constructs a Medicines instance with specified medicine name.
    Medicines(String... params)
    Constructs a Medicines instance by deserializing from an array of parameters.
    Medicines(String medicine, int stock, int alert_level)
    Constructs a Medicines instance with specified medicine name, stock level, and alert level.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    deserialise(String... params)
    Deserializes parameters into a Medicines object.
    int
    Returns the alert level for low stock.
    Returns the name of the medicine.
    int
    Returns the current stock level of the medicine.
    void
    Prints details of the medicine item to the console.
    Serializes the Medicines 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Medicines

      public Medicines(String medicine)
      Constructs a Medicines instance with specified medicine name.
      Parameters:
      medicine - the name of the medicine
    • Medicines

      public Medicines(String medicine, int stock, int alert_level)
      Constructs a Medicines instance with specified medicine name, stock level, and alert level.
      Parameters:
      medicine - the name of the medicine
      stock - the initial stock level of the medicine
      alert_level - the alert level for low stock
    • Medicines

      public Medicines(String... params)
      Constructs a Medicines instance by deserializing from an array of parameters.
      Parameters:
      params - an array of strings containing serialized data for the medicine
  • Method Details

    • deserialise

      public void deserialise(String... params)
      Deserializes parameters into a Medicines object.
      Specified by:
      deserialise in interface DatabaseItems
      Parameters:
      params - an array of strings containing serialized data for the medicine
    • serialise

      public String serialise()
      Serializes the Medicines object into a CSV format string.
      Specified by:
      serialise in interface DatabaseItems
      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 interface DatabaseItems
    • getMedicine

      public String 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

      public void setMedicine(String medicine)
      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