public void addEvent(Event event) {
   if (remainingDuration < event.getDurationInMinutes()) {
     throw new IllegalStateException(
         "Not enough room in this slot to fit the event: '" + event.getName() + "'");
   }
   events.add(event);
   remainingDuration -= event.getDurationInMinutes();
 }
  /**
   * Adds events to be added to the StringBuilder with their starting time and their duration.
   *
   * @param events the events to be added to the StringBuilder.
   * @param startTime the start time of the first event.
   * @param str the StringBuilder object to which the schedule must be added.
   * @return the time at which the events end.
   */
  private int addEventsSchedule(List<Event> events, int startTime, StringBuilder str) {
    int nextEventStartTime = startTime;
    for (Event event : events) {
      str.append(Time.minutesToDisplayTime(nextEventStartTime) + " " + event + NEW_LINE);
      nextEventStartTime += event.getDurationInMinutes();
    }

    return nextEventStartTime;
  }
 public boolean hasRoomFor(Event event) {
   return remainingDuration >= event.getDurationInMinutes();
 }