Subato

Appointment (endingTime)

class Appointment{
  DateTime time;
  int length;
  String reason;
  String place;

  Appointment(DateTime time, int length,String reason, String place){
    this.time = time;
    this.length = length;
    this.reason = reason;
    this.place = place;
  }
  
  public String toString(){
    return time+" "+reason+" "+place;
  }

  public DateTime endingTime() {
    int newday = time.date.day + ((time.time.hour + (length / 60)) / 24);
    Time t1 = time.time.minutesLater(length);
    Date d1 = new Date(newday, time.date.month, time.date.year);
    return new DateTime(d1, t1);
  }
  DateTime endingTime2(){
    int minutes = length % 60;
    int hoursLength = length/60;
    int hours = hoursLength % 24;
    int days = hoursLength/24;
    int nMin = (minutes+time.time.minute)%60;
    int nHourP24= (hours+time.time.hour+((minutes+time.time.minute)/60));
    Time t = new Time(nHourP24%24,nMin,time.time.second);
    Date d = new Date(days+time.date.day+nHourP24/24,time.date.month,time.date.year);
    return new DateTime(d,t);
  }
}