Medicine

public class Medicine

The domain object representing a single medicine in a dosage that is part of a pill regimen.

Fields

MEDICINE_END_DATE_CANNOT_BE_BEFORE_START_DATE

public static final String MEDICINE_END_DATE_CANNOT_BE_BEFORE_START_DATE

Error message for medicine validation.

Constructors

Medicine

public Medicine()

Constructs an instance without setting any fields.

Medicine

public Medicine(String name, LocalDate startDate, LocalDate endDate)

Creates a medicine instance using the provided data.

Parameters:
  • name – the name of the medicine
  • startDate – the start date for taking the medicine
  • endDate – the end date for taking this medicine, null means never-ending

Methods

equals

public boolean equals(Object o)

getEndDate

public LocalDate getEndDate()
Returns:the end date for taking the medicine, null means never-ending

getName

public String getName()
Returns:the name of the medicine

getStartDate

public LocalDate getStartDate()
Returns:the start date for taking the medicine

hashCode

public int hashCode()

setEndDate

public void setEndDate(LocalDate endDate)
Parameters:
  • endDate – the end date for taking the medicine, null means never-ending

setName

public void setName(String name)
Parameters:
  • name – the name of the medicine

setStartDate

public void setStartDate(LocalDate startDate)
Parameters:
  • startDate – the start date for taking the medicine

validate

public void validate()

Validates this medicine, by checking if the start date is not after the end date.

Throws: