示例#1
0
  /**
   * Show my schedule on the map. Every time "me"'s schedule shows, the map should be cleared of all
   * existing schedules, buildings, meetup locations, etc.
   */
  public void showMySchedule() {

    // clear any existing data on the map
    clearSchedules();
    activeDay = sharedPreferences.getString("dayOfWeek", "MWF");
    // get the sections wanted to display
    SortedSet<Section> mySections =
        studentManager.get(17013129).getSchedule().getSections(activeDay);
    // schedule plot for my schedule
    SchedulePlot mySchedulePlot = new SchedulePlot(mySections, "Xue Wen Zhou", "#01a9d4", 17301516);
    // CPSC 210 Students: You must complete the implementation of this method.
    // The very last part of the method should call the asynchronous
    // task (which you will also write the code for) to plot the route
    // for "me"'s schedule for the day of the week set in the Settings

    // Asynchronous tasks are a bit onerous to deal with. In order to provide
    // all information needed in one object to plot "me"'s route, we
    // create a SchedulePlot object and pass it to the asynchrous task.
    // See the project page for more details.

    // Get a routing between these points. This line of code creates and calls
    // an asynchronous task to do the calls to MapQuest to determine a route
    // and plots the route.
    // Assumes mySchedulePlot is a create and initialized SchedulePlot object

    // UNCOMMENT NEXT LINE ONCE YOU HAVE INSTANTIATED mySchedulePlot
    new GetRoutingForSchedule().execute(mySchedulePlot);
  }
示例#2
0
  /**
   * Initialize your schedule by coding it directly in. This is the schedule that will appear on the
   * map when you select "Show My Schedule".
   */
  private void initializeMySchedule() {
    // CPSC 210 Students; Implement this method
    me = new Student("Zhou", "Xue Wen", 17013129);
    // Schedule mySchedule = me.getSchedule();
    studentManager = new StudentManager();
    studentManager.addStudent("Zhou", "Xue Wen", 17013129);
    studentManager.addSectionToSchedule(17013129, "CPSC", 210, "202");
    studentManager.addSectionToSchedule(17013129, "JAPN", 100, "022");
    studentManager.addSectionToSchedule(17013129, "MATH", 302, "201");
    // studentManager.addSectionToSchedule(17013129,"CRWR",209,"002");
    //        Course cpsc210 = CourseFactory.getInstance().getCourse("CPSC", 210);
    //        Course japn100 = CourseFactory.getInstance().getCourse("JAPN", 100);
    //        Course math302 = CourseFactory.getInstance().getCourse("MATH", 302);
    //        //Course crwr209 = CourseFactory.getInstance().getCourse("CRWR", 209);
    //        //mySchedule.add(crwr209.getSection("002"));
    //        mySchedule.add(cpsc210.getSection("202"));
    //        mySchedule.add(japn100.getSection("022"));
    //        mySchedule.add(math302.getSection("201"));

  }
示例#3
0
  /**
   * Called when the end of an element is seen. (e.g., </title>)
   *
   * <p>Lookup documentation to learn meanings of parameters.
   */
  public void endElement(String uri, String localName, String qName) {
    if (qName.toLowerCase().equals("lastname")) lastName = accumulator.toString();
    else if (qName.toLowerCase().equals("firstname")) firstName = accumulator.toString();
    else if (qName.toLowerCase().equals("id")) id = accumulator.toString();

    if (qName.toLowerCase().equals("student")) {
      try {
        isValid(lastName, firstName);
      } catch (IllegalStudentException a) {
        a.getMessage();
      }
      if (id != null) {
        manager.addStudent(lastName, firstName, Integer.parseInt(id));
      }
    }
    // Reset the accumulator because we have seen the value
    accumulator.setLength(0);
  }
示例#4
0
 /**
  * Called when the parsing of an element starts. (e.g., <book>)
  *
  * <p>Lookup documentation to learn meanings of parameters.
  */
 @Override
 public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {
   if (qName.toLowerCase().equals("section")) {
     studentId = atts.getValue("StudentId");
     sectName = atts.getValue("name");
     sectCourseCode = atts.getValue("courseCode");
     sectCourseNumber = atts.getValue("courseNumber");
     if (studentId != null
         && sectName != null
         && sectCourseNumber != null
         && sectCourseCode != null)
       manager.addSectionToSchedule(
           Integer.parseInt(studentId),
           sectCourseCode,
           Integer.parseInt(sectCourseNumber),
           sectName);
   }
   accumulator.setLength(0);
 }
示例#5
0
  /**
   * Find all possible locations at which "me" and random student could meet up for the set day of
   * the week and the set time to meet and the set distance either "me" or random is willing to
   * travel to meet. A meetup is only possible if both "me" and random are free at the time
   * specified in the settings and each of us must have at least an hour (>= 60 minutes) free. You
   * should display dialog boxes if there are conditions under which no meetup can happen (e.g., me
   * or random is in class at the specified time)
   */
  public void findMeetupPlace() {
    // CPSC 210 students: you must complete this method
    activeBreakTime = sharedPreferences.getString("timeOfDay", "12");
    activeDay = sharedPreferences.getString("dayOfWeek", "MWF");
    activeDistance = sharedPreferences.getString("placeDistance", "250");
    me = studentManager.get(17013129);
    int bTime = Integer.parseInt(activeBreakTime);

    // case1: if me is not in school
    // case2: if rs is not in school
    // case 3: if one of the student does not have an one hour break
    // case 4: the two students are too far apart
    // case 5: there is no meetup place within selected range
    if (me.getSchedule().getSections(activeDay).size() == 0
        || me.getSchedule().startTime(activeDay).getHour() > bTime) {
      AlertDialog aDialog = createSimpleDialog("No MeetUp Place Available, You are not in School!");
      aDialog.show();
    } else if (randomStudent == null) {
      AlertDialog aDialog =
          createSimpleDialog("No MeetUp Place Available, You need a RandomStudent!");
      aDialog.show();
    } else if (randomStudent.getSchedule().getSections(activeDay).size() == 0
        || randomStudent.getSchedule().startTime(activeDay).getHour() > bTime) {
      AlertDialog aDialog =
          createSimpleDialog("No MeetUp Place Available, RandomStudent is not in School!");
      aDialog.show();
    } else if (!me.getSchedule().hasOneHourBreak(activeDay, activeBreakTime)) {
      AlertDialog aDialog =
          createSimpleDialog("No MeetUp Place Available, You DO NOT Have Enough BreakTime!");
      aDialog.show();
    } else if (!randomStudent.getSchedule().hasOneHourBreak(activeDay, activeBreakTime)) {
      AlertDialog aDialog =
          createSimpleDialog(
              "No MeetUp Place Available, RandomStudent DO NOT Have Enough BreakTime!");
      aDialog.show();
    } else {
      int distance = Integer.parseInt(activeDistance);
      displayAllPlacesWithinRange(
          me.getSchedule().whereAmI(activeDay, activeBreakTime),
          randomStudent.getSchedule().whereAmI(activeDay, activeBreakTime),
          distance);
    }
  }