Quick actions

cmd+k|ctrl+k

Navigation

Languages

Battleships

Snippet info

Language

Java

Visibility

public

Author

fxp007

Created

2016-05-07T01:02:18Z

Updated

2016-05-07T04:23:38Z

class Main {

    public static void main(String[] args) {
        // Create a battleshipCore instance
        BattleshipCore core = new BattleshipCore();

        // make a int array for location of battleship
        // [2,3,4]
        int[] locations = {2, 3, 4};

        // set cellLocations into battleshipCore
        core.setLocationCells(locations);

        // make a fake user guess
        // "4"
        String userGuess = "4";

        // call checkYourself with fake guess
        String result = core.checkYourself(userGuess);

        // if return "hit"
        if (result.equals("hit")) {
            System.out.println("success");
        } else {
            System.out.println("failed");
        }
    }
}
INFO