Пример #1
0
  public ArrayList<Task> search(Task task) throws InvalidCommandException {
    if (task.getDescription() != null) {
      return searchWagnerList(task.getDescription());

    } else {
      dataHandler.view(task);
      return dataHandler.getObservableList().getList();
    }
  }
Пример #2
0
  /**
   * get the list of tasks that their descriptions match with the string user wants to search.
   *
   * @param str1 the string user wants to search.
   * @return the list of the tasks that match the user's search.
   */
  public ArrayList<Task> searchWagnerList(String str1) {

    int distance;
    ArrayList<Task> tmp = new ArrayList<Task>();

    for (Task t : dataHandler.getAllTasks()) {
      String[] str2 = t.getDescription().split(" ");
      for (String s : str2) {

        distance = getDist(str1, s);

        if (distance < s.length() / 2) {
          tmp.add(t);
          break;
        }
      }
    }

    dataHandler.setDisplayedTasks(tmp);

    return tmp;
  }