Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ordination;
- import java.time.*;
- import java.time.temporal.ChronoUnit;
- public abstract class Medication {
- private LocalDate startDay;
- private LocalDate endDay;
- private Medicine medicine;
- public Medication(LocalDate startDay, LocalDate endDay, Medicine medicine) {
- this.startDay = startDay;
- this.endDay = endDay;
- this.medicine = medicine;
- }
- public LocalDate getStartDay() {
- return startDay;
- }
- public LocalDate getEndDay() {
- return endDay;
- }
- /**
- * Number of whole days between start and end date. Both days included.
- *
- * @return number of days the medication is valid for
- */
- public int numberDays() {
- return (int) ChronoUnit.DAYS.between(startDay, endDay) + 1;
- }
- @Override
- public String toString() {
- return startDen.toString();
- }
- /**
- * @return the total amount of medication given in the period that the medication is valid
- */
- public abstract double totalDosis();
- /**
- * @return the average dosis given pr day in the period the medication is valid
- */
- public abstract double dayDosis();
- /**
- * @return medication type as a String
- */
- public abstract String getType();
- public Medicine getMedicine() {
- return medicine;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement