walkthroughs/week-5-tdd/project/src/main/java/com/google/sps/FindMeetingQuery.java
public Collection<TimeRange> query(Collection<Event> events, MeetingRequest request) {
    long whole_day = 24*60;

    if (request.getAttendees().isEmpty() & request.getOptionalAttendees().isEmpty()) {
            return Arrays.asList(TimeRange.WHOLE_DAY);
    }

    if (request.getDuration() > whole_day) {
        return Arrays.asList();
    }
    if (!areAttendeesIncluded(events, request)) {
        if (request.getOptionalAttendees().isEmpty()){
            return Arrays.asList(TimeRange.WHOLE_DAY);
        }
        else {
            NoMandatoryAttendees = true;
        }  
    }
    List<Event> newEvents = sortEvents(events);    
  
    /*
    each event has one timeframe, our aim is to combine these timeframes together, in the best way possible:
        like takes care of overlapping events.
    */
   
    ArrayList<TimeRange> attendeesBookedTimes = getAllBookedTimeRanges(newEvents, request);

   
    //get the available time ranges, i.e those which aren't already booked,  and save it.
    Collection<TimeRange> availableTimeRanges = getAllTheAvailableTime(newEvents, attendeesBookedTimes, request);
    
   return availableTimeRanges;
  }
/**
   * This method uses the above helper functions to decide the available time 
   * based on the booked events and requested duration and attendees.
   * @param events It contains a collection of event objects
   * @param request It contains a MeetingRequest object.
   * @return Collection<TimeRange> contains all the time slot available.
   */
This method uses the above helper functions to decide the available time
based on the booked events and requested duration and attendees.
@param events It contains a collection of event objects
@param request It contains a MeetingRequest object.
@return Collection contains all the time slot available.
This method uses the above helper functions to decide the available time based on the booked events and requested duration and attendees . @param events It contains a collection of event objects @param request It contains a MeetingRequest object . @return Collection contains all the time slot available .
public Collection<TimeRange> query(Collection<Event> events, MeetingRequest request) {
    long whole_day = 24*60;
    if (request.getAttendees().isEmpty() & request.getOptionalAttendees().isEmpty()) {
            return Arrays.asList(TimeRange.WHOLE_DAY);
    }
    if (request.getDuration() > whole_day) {
        return Arrays.asList();
    }
    if (!areAttendeesIncluded(events, request)) {
        if (request.getOptionalAttendees().isEmpty()){
            return Arrays.asList(TimeRange.WHOLE_DAY);
        }
        else {
            NoMandatoryAttendees = true;
        }  
    }
    List<Event> newEvents = sortEvents(events);    
    /*
    each event has one timeframe, our aim is to combine these timeframes together, in the best way possible:
        like takes care of overlapping events.
    */
    ArrayList<TimeRange> attendeesBookedTimes = getAllBookedTimeRanges(newEvents, request);
    Collection<TimeRange> availableTimeRanges = getAllTheAvailableTime(newEvents, attendeesBookedTimes, request);
   return availableTimeRanges;
  }
public Collection < TimeRange > query ( Collection < Event > events , MeetingRequest request ) { long whole_day = 24 * 60 ; if ( request . getAttendees ( ) . isEmpty ( ) & request . getOptionalAttendees ( ) . isEmpty ( ) ) { return Arrays . asList ( TimeRange . WHOLE_DAY ) ; } if ( request . getDuration ( ) > whole_day ) { return Arrays . asList ( ) ; } if ( ! areAttendeesIncluded ( events , request ) ) { if ( request . getOptionalAttendees ( ) . isEmpty ( ) ) { return Arrays . asList ( TimeRange . WHOLE_DAY ) ; } else { NoMandatoryAttendees = true ; } } List < Event > newEvents = sortEvents ( events ) ; /*
    each event has one timeframe, our aim is to combine these timeframes together, in the best way possible:
        like takes care of overlapping events.
    */ ArrayList < TimeRange > attendeesBookedTimes = getAllBookedTimeRanges ( newEvents , request ) ; Collection < TimeRange > availableTimeRanges = getAllTheAvailableTime ( newEvents , attendeesBookedTimes , request ) ; return availableTimeRanges ; }
This method uses the above helper functions to decide the available time
 based on the booked events and requested duration and attendees.
This method uses the above helper functions to decide the available time based on the booked events and requested duration and attendees .
//get the available time ranges, i.e those which aren't already booked,  and save it.