[Demonstration 1]

[Buggy Method]
public void readFile(String fileName, String cutOff) {
    try {
        System.out.println("Number of students currently in directory: " + numOfStudents);
        reader = new Scanner(new File(fileName));
        int count = 0;
        int numOfStudents = 0;
        while (reader.hasNextLine()) {
            reader.nextLine();
            numOfStudents++;
        }
        numOfStudents = numOfStudents - 1;
        reader.close();
        reader = new Scanner(new File(fileName));
        int studentNum = 0;
        String headerLine = reader.nextLine();
        String[] headerToken = headerLine.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1);
        String studentLine = reader.nextLine();
        String[] data = studentLine.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1);
        while (true) {
            if (headerToken[count].contains("Student Name")) {
                fullName = (data[count]);
                //Last minute add
                String[] name = fullName.split(",");
                firstName = name[1];
                lastName = name[0];
            } else if (headerToken[count].contains("FIRST NAME")) {
                firstName = (data[count]);
            } else if (headerToken[count].contains("LAST NAME")) {
                lastName = (data[count]);
            } else if (headerToken[count].contains("Id") || headerToken[count].contains("ID")) {
                id = (data[count]);
            } else if (headerToken[count].contains("Assignment")) {
                Assignment assignment = new Assignment(cutOff + "-" + headerToken[count], data[count], data[count + 1]);
                assignments.add(assignment);
                count++;
            } else if (headerToken[count].contains("project") || headerToken[count].contains("Project") || headerToken[count].contains("ray") || headerToken[count].contains("Sprint") || headerToken[count].contains("Paper")) {
                Project project = new Project(headerToken[count], data[count], data[count + 1]);
                projects.add(project);
                count++;
            } else if (headerToken[count].contains("Exam")) {
                exams.add(data[count]);
            } else if (headerToken[count].contains("Final")) {
                finalExam = (data[count]);
            } else if (headerToken[count].contains("Total")) {
                total = (data[count]);
            }
            if (headerToken[count].contains("grade") || headerToken[count].contains("Grade")) {
                letterGrade = (data[count] + "," + cutOff);
                Student student = new Student(firstName, lastName, id, assignments, projects, exams, total, finalExam, letterGrade);
                students.add(student);
                count = -1;
                studentNum++;
                if (numOfStudents == studentNum) {
                    break;
                }
                studentLine = reader.nextLine();
                data = studentLine.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1);
            }
            count++;
            //System.out.println(students.size());
        }
        System.out.println("Successfully added file to repository");
        System.out.println("Number of students read: " + numOfStudents);
        reader.close();
    } catch (FileNotFoundException ex) {
        System.out.println("Unable to open file '" + fileName + "'");
    } catch (IOException ex) {
        System.out.println("Error reading file: " + fileName);
        System.exit(1);
    }
}

[Buggy Hunk]
System.out.println("Number of students currently in directory: " +numOfStudents);

[Patch]
System.out.println("Number of students currently in directory: " +students.size());

[Demonstration 2]

[Buggy Method]
private void addItemOrderButtonActionPerformed(java.awt.event.ActionEvent evt) {
    cupcakedb.addToRequest(itemOrderComboBox, orderTable, itemOrderSpinner);
    this.updateOrderTotal();
}

[Buggy Hunk]
cupcakedb.addToRequest(itemOrderComboBox, orderTable, itemOrderSpinner);

[Patch]
cupcakedb.addToRequest(itemOrderComboBox, orderTable, itemOrderSpinner, layerNewOrder);

[Demonstration 3]

[Buggy Method]
@PUT
@Path("/{id}")
@Timed
@UnitOfWork
public Response put(@PathParam("id") @NotNull Long id, @NotNull @Valid Home home) {
    if (!id.equals(home.getId())) {
        return Response.created(UriBuilder.fromResource(HomeResource.class).build(id, home.getId())).status(HttpStatus.CONFLICT_409).build();
    }
    HomeEntity entity = homeDAO.findById(id);
    if (entity == null) {
        return Response.created(UriBuilder.fromResource(HomeResource.class).build(id, home.getId())).status(HttpStatus.NOT_FOUND_404).build();
    }
    entity.setStreetAddressLine1(home.getStreetAddressLine1());
    entity.setStreetAddressLine2(home.getStreetAddressLine2());
    entity.setCity(home.getCity());
    entity.setState(home.getState());
    entity.setZipCode(home.getZipCode());
    entity.setZipCode(home.getCountry());
    HomeEntity newHome = homeDAO.save(entity);
    return Response.created(UriBuilder.fromResource(HomeResource.class).build(newHome.getId())).status(HttpStatus.ACCEPTED_202).build();
}

[Buggy Hunk]
entity.setZipCode(home.getCountry());

[Patch]
entity.setCountry(home.getCountry());