/**
   * Gets status of each day selection button and returns an arraylist of '{@link Day}'s
   *
   * @return ArrayList of type '{@link Day}'
   * @see Day
   */
  private ArrayList<Day> getDays() {
    ArrayList<Day> results = new ArrayList<>();

    if (sundayToggleButton.isChecked()) results.add(Day.valueOf("SU"));
    if (mondayToggleButton.isChecked()) results.add(Day.valueOf("M"));
    if (tuesdayToggleButton.isChecked()) results.add(Day.valueOf("TU"));
    if (wednesdayToggleButton.isChecked()) results.add(Day.valueOf("W"));
    if (thursdayToggleButton.isChecked()) results.add(Day.valueOf("TH"));
    if (fridayToggleButton.isChecked()) results.add(Day.valueOf("F"));
    if (saturdayToggleButton.isChecked()) results.add(Day.valueOf("SA"));

    return results;
  }
  /**
   * Constructor to build Section from JSON
   *
   * @param jsonObject JSON Object must have the following keys present:
   *     <ul>
   *       <li>"CourseNumber" - integer, unique to all classes, UTA Class ID Number
   *       <li>"Section" - integer, unique within course, UTA Section Number
   *       <li>"Room" - String, room the section will meet in
   *       <li>"Instructor" - String, list of instructors for section
   *       <li>"MeetingTime" - String, time the lecture period will begin to time the lecture period
   *           will end
   *       <li>"MeetingDays" - String, JSON Array of days class will be meeting
   *       <li>"Status" - String, current class status (OPEN, CLOSED, WAIT_LIST)
   *           <ul/>
   * @param sourceCourse Course this section belongs to. Used primarily to recreate JSON.
   * @throws JSONException
   */
  Section(JSONObject jsonObject, Course sourceCourse) throws JSONException {

    this.setSectionID(Integer.parseInt(jsonObject.getString("CourseNumber")));

    this.setSectionNumber(Integer.parseInt(jsonObject.getString("Section")));

    this.setRoom(jsonObject.getString("Room"));

    this.setInstructors(jsonObject.getString("Instructor"));

    String times[] = jsonObject.getString("MeetingTime").split("-");
    Log.i("New Start Time", times[0]);
    if (times[0].equalsIgnoreCase("UNKNOWN/TBA")) {
      startTime = (new TimeShort(0, 0));
      endTime = (new TimeShort(0, 0));
    } else if (!times[0].equalsIgnoreCase("TBA")) {
      startTime = (new TimeShort(times[0]));
      endTime = (new TimeShort(times[1]));
    } else {
      startTime = (new TimeShort(0, 0));
      endTime = (new TimeShort(0, 0));
    }

    JSONArray jsonDaysArray = jsonObject.getJSONArray("MeetingDays");
    Log.i("New Section Days List", jsonDaysArray.toString());

    days = new ArrayList<>(jsonDaysArray.length());

    for (int index = jsonDaysArray.length(); index != 0; index--) {
      Day temp = Day.valueOf(jsonDaysArray.getString(index - 1));
      days.add(temp);
      Log.i("New Section Day", days.get(days.size() - 1).toString());
    }
    Collections.reverse(days);
    Log.i("New Section #of Days", ((Integer) days.size()).toString());
    for (Day day : days) {
      Log.i("Day in Section", day.toString());
    }
    Log.i("New Section Days", days.toString());

    this.setStatus(
        ClassStatus.valueOf(jsonObject.getString("Status").toUpperCase().replace(" ", "_")));

    this.setSourceCourse(sourceCourse);
  }