Advertisement
LoganBlackisle

Medication

Sep 15th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. package ordination;
  2.  
  3. import java.time.*;
  4. import java.time.temporal.ChronoUnit;
  5.  
  6. public abstract class Medication {
  7.     private LocalDate startDay;
  8.     private LocalDate endDay;
  9.     private Medicine medicine;
  10.  
  11.     public Medication(LocalDate startDay, LocalDate endDay, Medicine medicine) {
  12.         this.startDay = startDay;
  13.         this.endDay = endDay;
  14.         this.medicine = medicine;
  15.     }
  16.  
  17.     public LocalDate getStartDay() {
  18.         return startDay;
  19.     }
  20.  
  21.     public LocalDate getEndDay() {
  22.         return endDay;
  23.     }
  24.  
  25.     /**
  26.      * Number of whole days between start and end date. Both days included.
  27.      *
  28.      * @return number of days the medication is valid for
  29.      */
  30.     public int numberDays() {
  31.         return (int) ChronoUnit.DAYS.between(startDay, endDay) + 1;
  32.     }
  33.  
  34.     @Override
  35.     public String toString() {
  36.         return startDen.toString();
  37.     }
  38.  
  39.     /**
  40.      * @return the total amount of medication given in the period that the medication is valid
  41.      */
  42.     public abstract double totalDosis();
  43.  
  44.     /**
  45.      * @return the average dosis given pr day in the period the medication is valid
  46.      */
  47.     public abstract double dayDosis();
  48.  
  49.     /**
  50.      * @return medication type as a String
  51.      */
  52.     public abstract String getType();
  53.  
  54.     public Medicine getMedicine() {
  55.         return medicine;
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement