[Demonstration 1]

[Buggy Method]
public ResultSet execute(String userContent, TaskListSet allLists, Validation validOp) {
    int lineNum = Integer.parseInt(userContent.substring(0, userContent.indexOf(" ")));
    ArrayList<Task> tempList = new ArrayList<Task>();
    tempList = allLists.getTaskList();
    ResultSet returnResult = new ResultSet();
    String taskStartTime = null;
    String taskEndTime = null;
    DateAndTime dateTimeCheck = new DateAndTime();
    LocalTime startTime = null;
    LocalTime endTime = null;
    if (validOp.isValidTask(lineNum, allLists)) {
        int taskID = validOp.checkForTaskID(lineNum, allLists);
        String editContent = userContent.substring(userContent.indexOf(" "));
        if (editContent.indexOf(" ") >= 0) {
            if (editContent.contains(dateFieldIdentifier)) {
                LocalDate dueDate = dateTime.determineDate(editContent.substring(editContent.indexOf(dateFieldIdentifier) + 1));
                tempList.get(taskID).setDueDate(dueDate);
            } else if (editContent.contains(timeFieldIdentifier)) {
                String timeInfo = editContent.substring(editContent.indexOf(timeFieldIdentifier) + 1);
                if (timeInfo.contains(timeFieldSeparator)) {
                    taskStartTime = timeInfo.substring(0, timeInfo.indexOf(timeFieldSeparator));
                    taskEndTime = timeInfo.substring(timeInfo.indexOf(timeFieldSeparator) + 1);
                    startTime = dateTimeCheck.determineTime(taskStartTime);
                    endTime = dateTimeCheck.determineTime(taskEndTime);
                    if ((startTime == null && endTime == null) || (endTime != null && tempList.get(taskID).getStartTime() == null)) {
                        returnResult.setOpStatus(MESSAGE_INVALID_CONTENT);
                        return returnResult;
                    } else if (endTime != null && tempList.get(taskID).getStartTime() != null) {
                        tempList.get(taskID).setEndTime(endTime);
                    } else if (startTime != null && tempList.get(taskID).getEndTime() != null) {
                        tempList.get(taskID).setStartTime(startTime);
                    } else if (startTime != null && tempList.get(taskID).getEndTime() == null) {
                        tempList.get(taskID).setStartTime(startTime);
                        tempList.get(taskID).setEndTime(startTime.plusHours(TASK_DURATION));
                    } else {
                        tempList.get(taskID).setStartTime(startTime);
                        tempList.get(taskID).setEndTime(endTime);
                    }
                } else {
                    startTime = dateTimeCheck.determineTime(timeInfo);
                    if (startTime == null) {
                        returnResult.setOpStatus(MESSAGE_INVALID_CONTENT);
                        return returnResult;
                    } else {
                        tempList.get(taskID).setStartTime(startTime);
                    }
                }
            } else {
                tempList.get(taskID).setTaskName(editContent.substring(1));
            }
            returnResult.setOpStatus(String.format(MESSAGE_SUCCESS));
        } else {
            returnResult.setOpStatus(MESSAGE_INVALID_CONTENT);
        }
    } else {
        returnResult.setOpStatus(MESSAGE_INVALID_TASK);
    }
    allLists.setTaskList(tempList);
    returnResult.setReturnList(allLists.getTaskList());
    return returnResult;
}

[Buggy Hunk]
if((startTime == null && endTime == null) || (endTime != null && tempList.get(taskID).getStartTime() == null)) {

[Patch]
if((startTime == null && endTime == null) || (endTime != null && startTime == null && tempList.get(taskID).getStartTime() == null)) {

[Demonstration 2]

[Buggy Method]
@Test
public void allFunctionsTest() {
    String feedback = null;
    //Add task
    feedback = logic.parseCommand("first test task", Logic.ListType.ALL);
    assertEquals(feedback, "first test task");
    logic.executeCommand();
    logic.undo();
    logic.redo();
    //Edit task
    feedback = logic.parseCommand("edited task", Logic.ListType.ALL);
    assertEquals(feedback, "edited task");
    logic.editTask(Logic.ListType.ALL, 1);
    logic.undo();
    logic.redo();
    //Delete a task
    feedback = logic.parseCommand("del 1", Logic.ListType.ALL);
    assertEquals(feedback, "edited task");
    logic.executeCommand();
    logic.undo();
    logic.redo();
    //Delete multiple task
    logic.parseCommand("c multiple task", Logic.ListType.ALL);
    logic.executeCommand();
    logic.parseCommand("b multiple task", Logic.ListType.ALL);
    logic.executeCommand();
    logic.parseCommand("a multiple task", Logic.ListType.ALL);
    logic.executeCommand();
    feedback = logic.parseCommand("del 1-2,3", Logic.ListType.ALL);
    assertEquals(feedback, "1-2,3 (3 tasks)");
    logic.executeCommand();
    logic.undo();
    logic.redo();
    //Sorting test
    feedback = logic.parseCommand("c multiple task by 8", Logic.ListType.ALL);
    logic.executeCommand();
    feedback = logic.parseCommand("a multiple task by 10", Logic.ListType.ALL);
    logic.executeCommand();
    feedback = logic.parseCommand("b multiple task by 8", Logic.ListType.ALL);
    logic.executeCommand();
    feedback = logic.parseCommand("del 1-2,3", Logic.ListType.ALL);
    assertEquals(feedback, "1-2,3 (3 tasks)");
    logic.executeCommand();
}

[Buggy Hunk]
logic.editTask(Logic.ListType.ALL, 1);

[Patch]
logic.editTask(1, Logic.ListType.ALL);

[Demonstration 3]

[Buggy Method]
private Event classifyDataFromPreposition(Event task, String input, String preposition, int startIndex, int endIndex) throws ParseException {
    Date inputDate;
    String stringDate = null;
    String time = null;
    String name = null;
    boolean isDay = false;
    int newStartIndex = 0;
    int newEndIndex = 0;
    SimpleDateFormat formatToString = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
    if (task.getName().isEmpty() && isNameDefined) {
        name = input.substring(startIndex, endIndex).trim();
        task.setName(name);
    }
    if (task.getName().isEmpty()) {
        task = null;
        return task;
    }
    if (preposition.equalsIgnoreCase(PREP_ON)) {
        newStartIndex = endIndex + PREP_ON.length() + 1;
        newEndIndex = matchPatternOfFirstOccurrence(PATTERN_AT_OR_BY_OR_NEXT, input)[0];
        if (newEndIndex == 0) {
            newEndIndex = input.length();
        } else if (newEndIndex > newStartIndex) {
            isAfterOn = true;
        }
        extractDateFromOnPreposition(task, input, newStartIndex, newEndIndex, formatToString);
    } else if (preposition.equalsIgnoreCase(PREP_AT)) {
        /*check for anymore preposition 'at' which describe location*/
        newStartIndex = endIndex + PREP_AT.length() + 1;
        newEndIndex = matchPatternOfLastOccurrence(PATTERN_AT, input)[0];
        if (newEndIndex == 0) {
            newEndIndex = input.length();
        } else if (newEndIndex < newStartIndex) {
            newEndIndex = input.length();
        }
        extractDateFromAtPreposition(task, input, newStartIndex, newEndIndex, formatToString);
    } else if (preposition.equalsIgnoreCase(PREP_BY)) {
        newStartIndex = endIndex + PREP_BY.length() + 1;
        newEndIndex = matchPatternOfLastOccurrence(PATTERN_AT, input)[0];
        /* no more preposition, the end of the line*/
        if (newEndIndex == 0) {
            newEndIndex = input.length();
        }
        extractDateFromByPreposition(task, input, newStartIndex, newEndIndex, formatToString);
    } else if (preposition.equalsIgnoreCase(PREP_FROM)) {
        newStartIndex = endIndex + PREP_FROM.length() + 1;
        newEndIndex = matchPatternOfFirstOccurrence(PATTERN_TO, input)[0];
        if (newEndIndex == 0) {
            return null;
        }
        extractDateFromFromPreposition(task, input, newStartIndex, newEndIndex, formatToString);
        newStartIndex = matchPatternOfFirstOccurrence(PATTERN_TO, input)[1] + 1;
        newEndIndex = matchPatternOfFirstOccurrence(PATTERN_AT, input)[0];
        if (newEndIndex == 0) {
            newEndIndex = input.length();
        } else if (newEndIndex < newStartIndex) {
            newEndIndex = input.length();
        }
        extractDateFromToPreposition(task, input, newStartIndex, newEndIndex);
    } else if (preposition.equalsIgnoreCase(PREP_NEXT)) {
        newStartIndex = endIndex + PREP_NEXT.length() + 1;
        newEndIndex = matchPatternOfFirstOccurrence(PATTERN_AT_OR_BY, input)[0];
        if (newEndIndex == 0) {
            newEndIndex = input.length();
        } else if (newEndIndex > newStartIndex) {
            isAfterNext = true;
        }
        task = extractDateFromNextPreposition(task, input, newStartIndex, newEndIndex, formatToString);
    } else if (preposition.equalsIgnoreCase(PREP_AFTER_NEXT)) {
    } else if (preposition.equalsIgnoreCase(PREP_BEFORE)) {
    }
    return task;
}

[Buggy Hunk]
if(task.getName().isEmpty()){

[Patch]
if(task.getName().isEmpty() && !isEdit){