Ejemplo n.º 1
0
 private boolean collidesWith(CourseSelection e) {
   for (CourseSelection cs : courseSelections) {
     if (e.overlaps(cs)) {
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 2
0
  public String toString() {
    String plural = courseSelections.size() > 1 ? "es" : "";
    String outputString = ("Schedule: " + courseSelections.size() + " class" + plural + ".");
    SimpleDateFormat date_format = new SimpleDateFormat("HH:mm");
    outputString =
        new String(
                outputString
                    + System.getProperty("line.separator")
                    + "Statistics:\t\tAvg Start: "
                    + date_format.format(avgStartingTime)
                    + ", Avg End: "
                    + date_format.format(avgEndingTime))
            + ", Avg Length: "
            + (avgLengthOfDay.getTime() / 1000 / 60 / 60)
            + " hours, Days off: "
            + numOfDaysOff;

    outputString =
        new String(
                outputString
                    + System.getProperty("line.separator")
                    + "Ignoring DGDs/TUTs:\tAvg Start: "
                    + date_format.format(ignoreExtrasAvgStartingTime)
                    + ", Avg End: "
                    + date_format.format(ignoreExtrasAvgEndingTime))
            + ", Avg Length: "
            + (ignoreExtrasAvgLengthOfDay.getTime() / 1000 / 60 / 60)
            + " hours, Days off: "
            + ignoreExtrasNumOfDaysOff
            + System.getProperty("line.separator");

    for (CourseSelection cs : courseSelections) {
      outputString =
          new String(
              outputString
                  + cs.getActivity(0).getSection().getName()
                  + System.getProperty("line.separator"));
      for (Activity a : cs.getActivities()) {
        outputString = new String(outputString + a.toString());
      }
    }

    return outputString;
  }
Ejemplo n.º 3
0
  public void updateStats() {
    numOfDaysOff = 0;
    ignoreExtrasNumOfDaysOff = 0;

    Long totalStartTime = (long) 0;
    Long totalEndTime = (long) 0;
    Long totalLengthOfDay = (long) 0;

    Long ieTotalStartTime = (long) 0;
    Long ieTotalEndTime = (long) 0;
    Long ieTotalLengthOfDay = (long) 0;

    for (int i = 1; i <= 7; i++) {
      Date earliestStartTime = null;
      Date latestEndTime = null;

      // ie: Ignore Extras (DGD, TUT)
      Date ieEarliestStartTime = null;
      Date ieLatestEndTime = null;

      boolean dayOff = true;
      boolean ieDayOff = true;
      for (CourseSelection cs : courseSelections) {
        for (Activity a : cs.getActivities()) {
          if (a.getDay() == i) {
            if (dayOff) {
              dayOff = false;
              earliestStartTime = a.getStartTime();
              latestEndTime = a.getEndTime();
            } else {
              if (a.getStartTime().before(earliestStartTime)) {
                earliestStartTime = a.getStartTime();
              }
              if (a.getEndTime().after(latestEndTime)) {
                latestEndTime = a.getEndTime();
              }
            }

            if (!(a.getType().equals("DGD") || a.getType().equals("TUT"))) {
              if (ieDayOff) {
                ieDayOff = false;
                ieEarliestStartTime = a.getStartTime();
                ieLatestEndTime = a.getEndTime();
              } else {
                if (a.getStartTime().before(ieEarliestStartTime)) {
                  ieEarliestStartTime = a.getStartTime();
                }
                if (a.getEndTime().after(latestEndTime)) {
                  ieLatestEndTime = a.getEndTime();
                }
              }
            }
          }
        }
      }

      if (dayOff) {
        numOfDaysOff++;
      } else {
        totalStartTime += earliestStartTime.getTime();
        totalEndTime += latestEndTime.getTime();
        totalLengthOfDay += (latestEndTime.getTime() - earliestStartTime.getTime());
      }

      if (ieDayOff) {
        ignoreExtrasNumOfDaysOff++;
      } else {
        ieTotalStartTime += ieEarliestStartTime.getTime();
        ieTotalEndTime += ieLatestEndTime.getTime();
        ieTotalLengthOfDay += (ieLatestEndTime.getTime() - ieEarliestStartTime.getTime());
      }
    }
    if (numOfDaysOff != 7) {
      avgStartingTime = new Date(totalStartTime / (7 - numOfDaysOff));
      avgEndingTime = new Date(totalEndTime / (7 - numOfDaysOff));
      avgLengthOfDay = new Date(totalLengthOfDay / (7 - numOfDaysOff));

      ignoreExtrasAvgStartingTime = new Date(ieTotalStartTime / (7 - ignoreExtrasNumOfDaysOff));
      ignoreExtrasAvgEndingTime = new Date(ieTotalEndTime / (7 - ignoreExtrasNumOfDaysOff));
      ignoreExtrasAvgLengthOfDay = new Date(ieTotalLengthOfDay / (7 - ignoreExtrasNumOfDaysOff));
    }
  }