<commit_before>// ShipController.java
package de.htwg.battleship.controller;

import de.htwg.battleship.model.Player;
import de.htwg.battleship.model.Ship;

/**
 * ShipController to place the ships and test if there are collisions.
 * to test that it uses another controller which uses a
 * chain-of-responsibility-pattern
 * @author <NAME> (<EMAIL>)
 * @version 1.00
 * @since 2014-11-27
 */
public class ShipController {

    /**
     * Player one.
     */
    private final Player player1;
    /**
     * Player two.
     */
    private final Player player2;

    /**
     * Controller with a chain of responsibility.
     */
    private CollisionController cc;

    /**
     * Public Constructor.
     *
     * @param player1 first player
     * @param player2 second player
     */
    public ShipController(final Player player1, final Player player2) {
        this.player1 = player1;
        this.player2 = player2;
        this.cc = new CollisionOrientationBothTrue();
    }

    /**
     * Method to place a Ship on the board.
     *
     * @param ship to add on the board
     * @param player true for the first, false for the second player
     * @return true if it is possible and set, false if not
     */
    public final boolean placeShip(final Ship ship, final boolean player) {
        if (player) {
            return playerShip(ship, player1);
        }
        return playerShip(ship, player2);
    }

    /**
     * Utility-Method to set a ship for a specified player.
     *
     * @param ship to place
     * @param player which player
     * @return true if it is set, false if not
     */
    private boolean playerShip(final Ship ship, final Player player) {
        Ship[] shipList = player.getOwnBoard().getShipList();
        for (Ship shipIn : shipList) {
            if (isCollision(ship, shipIn)) {
                return false;
            }
        }
        player.getOwnBoard().addShip(ship);
        return true;
    }

    /**
     * Tests if two ships collide.
     *
     * @param ship on the board
     * @param shipIn to place
     * @return true if they collide
     */
    private boolean isCollision(final Ship ship, final Ship shipIn) {
        return cc.responsibility(shipIn, ship);
    }
}<commit_msg>fixed a fatal bug in player Ship<commit_after>// ShipController.java
package de.htwg.battleship.controller;

import de.htwg.battleship.model.Player;
import de.htwg.battleship.model.Ship;

/**
 * ShipController to place the ships and test if there are collisions.
 * to test that it uses another controller which uses a
 * chain-of-responsibility-pattern
 * @author <NAME> (<EMAIL>)
 * @version 1.00
 * @since 2014-11-27
 */
public class ShipController {

    /**
     * Player one.
     */
    private final Player player1;
    /**
     * Player two.
     */
    private final Player player2;

    /**
     * Controller with a chain of responsibility.
     */
    private CollisionController cc;

    /**
     * Public Constructor.
     *
     * @param player1 first player
     * @param player2 second player
     */
    public ShipController(final Player player1, final Player player2) {
        this.player1 = player1;
        this.player2 = player2;
        this.cc = new CollisionOrientationBothTrue();
    }

    /**
     * Method to place a Ship on the board.
     *
     * @param ship to add on the board
     * @param player true for the first, false for the second player
     * @return true if it is possible and set, false if not
     */
    public final boolean placeShip(final Ship ship, final boolean player) {
        if (player) {
            return playerShip(ship, player1);
        }
        return playerShip(ship, player2);
    }

    /**
     * Utility-Method to set a ship for a specified player.
     *
     * @param ship to place
     * @param player which player
     * @return true if it is set, false if not
     */
    private boolean playerShip(final Ship ship, final Player player) {
        Ship[] shipList = player.getOwnBoard().getShipList();
        for (int i = 0; i < player.getOwnBoard().getShips(); i++) {
            if (isCollision(ship, shipList[i])) {
                return false;
            }
        }
        player.getOwnBoard().addShip(ship);
        return true;
    }

    /**
     * Tests if two ships collide.
     *
     * @param ship on the board
     * @param shipIn to place
     * @return true if they collide
     */
    private boolean isCollision(final Ship ship, final Ship shipIn) {
        return cc.responsibility(shipIn, ship);
    }
}
{'fraction_non_alphanumeric': 0.0951021304634307, 'fraction_numerical': 0.010322864045684164, 'mean_word_length': 2.1559251559251558, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2563487', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1296, 'n_words': 445}