[Demonstration 1]

[Buggy Method]
@Override
public void mouseReleased(MouseEvent mouseEvent) {
    if (SwingUtilities.isRightMouseButton(mouseEvent))
        return;
    layeredPane.setCursor(null);
    if (currentShip == null)
        return;
    int x = mouseEvent.getX() + deltaX;
    int y = mouseEvent.getY() + deltaY;
    if (currentShip.isVertical()) {
        x = Math.max(0, x);
        x = Math.min(x, layeredPane.getWidth() - SQUARE_LENGTH);
        y = Math.max(0, y);
        y = Math.min(y, layeredPane.getHeight() - SQUARE_LENGTH * currentShip.getLength());
    } else {
        x = Math.max(0, x);
        x = Math.min(x, layeredPane.getWidth() - SQUARE_LENGTH * currentShip.getLength());
        y = Math.max(0, y);
        y = Math.min(y, layeredPane.getHeight() - SQUARE_LENGTH);
    }
    x = x + SQUARE_LENGTH / 2;
    y = y + SQUARE_LENGTH / 2;
    if (currentShip.isVertical()) {
        if (x > SQUARE_LENGTH * NUMBER_COLUMNS) {
            currentShip.reset();
            playBtn.setVisible(false);
            playerName.setVisible(false);
            playerNameText.setVisible(false);
            difficultyLabel.setVisible(false);
            aiLevelBox.setVisible(false);
            currentShip = null;
            return;
        }
    } else {
        if (x + currentShip.getLength() * SQUARE_LENGTH > SQUARE_LENGTH * NUMBER_COLUMNS) {
            currentShip.reset();
            playBtn.setVisible(false);
            playerNameText.setVisible(false);
            playerName.setVisible(false);
            difficultyLabel.setVisible(false);
            aiLevelBox.setVisible(false);
            currentShip = null;
            return;
        }
    }
    currentShip.setThings(y / SQUARE_LENGTH, x / SQUARE_LENGTH);
    if (checkIntersect(currentShip)) {
        currentShip.setBackToLastLocation();
    }
    currentShip.setLocation(currentShip.getXPixel(), currentShip.getYPixel());
    currentShip = null;
    difficultyLabel.setVisible(isAllShipDeployed());
    playerNameText.setVisible(isAllShipDeployed());
    playerName.setVisible(isAllShipDeployed());
    aiLevelBox.setVisible(isAllShipDeployed());
    playBtn.setVisible(isAllShipDeployed());
}

[Buggy Hunk]
if (x + currentShip.getLength() * SQUARE_LENGTH > SQUARE_LENGTH * NUMBER_COLUMNS) {

[Patch]
if (x + currentShip.getLength() * SQUARE_LENGTH-SQUARE_LENGTH/2> SQUARE_LENGTH * NUMBER_COLUMNS) {

[Demonstration 2]

[Buggy Method]
private boolean placeShips(GameModel game, int playerNumber) {
    // Get the player's table of ships and game grid
    Hashtable<String, Ship> ships;
    Player player;
    if (playerNumber == 1) {
        player = game.getPlayer1();
        ships = player.getShips();
    } else if (playerNumber == 2) {
        player = game.getPlayer2();
        ships = player.getShips();
    } else {
        // Return false if an invalid player number is provided
        return false;
    }
    // Iterate through the Hashtable of ships to place them
    Set<String> keys = ships.keySet();
    for (String key : keys) {
        Ship currentShip = ships.get(key);
        int length = currentShip.getHits();
        // Select a random number 0-1 to determine orientation of ship
        Random rand = new Random();
        int orientation = rand.nextInt(2);
        // Loop picking random locations until we find one that is not already occupied
        while (true) {
            Point[] currentPoints = new Point[length];
            if (orientation == 0) {
                // Horizontal orientation
                // Select a random starting point
                // subtract the length so it won't overflow the board
                int x = rand.nextInt(10 - length);
                int y = rand.nextInt(10);
                // Create points
                for (int i = 0; i < length; i++) {
                    currentPoints[i] = new Point(x + i, y, false);
                }
            } else {
                // Vertical orientation
                // Select a random starting point
                int x = rand.nextInt(10);
                // subtract the length so it won't overflow the board
                int y = rand.nextInt(10 - length);
                // Create points
                for (int i = 0; i < length; i++) {
                    currentPoints[i] = new Point(x, y + i, false);
                }
            }
            // Check if there is already a ship in this location
            boolean shipOverlaps = false;
            for (Point p : currentPoints) {
                shipOverlaps = player.hasShipOnPoint(p);
                // stop checking if we already know one overlaps
                if (shipOverlaps)
                    break;
            }
            // If no ships overlap, set the location for this ship
            // Otherwise, while loop will restart
            if (shipOverlaps == false) {
                currentShip.setLocation(new Location(currentPoints));
                break;
            }
        }
    }
    return true;
}

[Buggy Hunk]
int length = currentShip.getHits();

[Patch]
int length = ((Ship) currentShip).getHits();

[Demonstration 3]

[Buggy Method]
@ReactMethod
public void trackEventWithCustomDimensionValues(String trackerId, String category, String action, ReadableMap optionalValues, ReadableMap dimensionIndexValues) {
    self.trackEventWithCustomDimensionAndMetricValues(trackerId, category, action, optionalValues, dimensionIndexValues, null);
}

[Buggy Hunk]
self.trackEventWithCustomDimensionAndMetricValues(trackerId, category, action, optionalValues, dimensionIndexValues, null);

[Patch]
this.trackEventWithCustomDimensionAndMetricValues(trackerId, category, action, optionalValues, dimensionIndexValues, null);