{"action":"created","comment":{"url":"https://api.github.com/repos/MinionsGroup/devfund-h/pulls/comments/205431213","pull_request_review_id":140696538,"id":205431213,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNTQzMTIxMw==","diff_hunk":"@@ -0,0 +1,184 @@\n+package org.minions.devfund.damianvp;\n+\n+import java.util.Arrays;\n+import java.util.Random;\n+import java.util.logging.Level;\n+import java.util.logging.Logger;\n+\n+/**\n+ * Class to build whack a mole game.\n+ */\n+public class WhackAMole {\n+    private int score;\n+    private int molesLeft;\n+    private int attemptsLeft;\n+    private char[][] moleGrid;\n+    private char[][] trackerMoleGrid;\n+    static final char MOLE = 'M';\n+    static final char EMPTY = '*';\n+    static final char WHACKED = 'W';\n+    static final int INVALID_RANGE = -2;\n+    private static final Logger LOGGER = Logger.getLogger(WhackAMole.class.getName());\n+\n+    /**\n+     * constructor class.\n+     * @param numAttempts num of attempts available for game\n+     * @param gridDimension dimension of grid game\n+     */\n+    WhackAMole(int numAttempts, int gridDimension) {\n+        this.attemptsLeft = numAttempts;\n+        this.moleGrid = initializeGrid(gridDimension);\n+        this.trackerMoleGrid = initializeGrid(gridDimension);\n+        this.molesLeft = 0;\n+        this.score = 0;\n+    }\n+\n+    /**\n+     * Initialize the grid game with empty values.\n+     * @param gridDimension  dimension of grid to build.\n+     * @return a grid loaded with empty values.\n+     */\n+    private char[][] initializeGrid(int gridDimension) {\n+        char[][] grid = new char[gridDimension][gridDimension];\n+        for (char[] row: grid) {\n+            Arrays.fill(row, EMPTY);\n+        }\n+        return grid;\n+    }\n+\n+    /**\n+     * Method to place a specific mole by Location x, y.\n+     * @param x  x location of grid.\n+     * @param y  y location of grid.\n+     * @return  true, if place is successful.\n+     *          false, if place was not performed.\n+     */\n+    boolean place(int x, int y) {\n+        if (validatedCoordinates(x, y) && this.moleGrid[x][y] != MOLE) {\n+            this.moleGrid[x][y] = MOLE;\n+            this.molesLeft++;\n+            return true;\n+        }\n+        return false;\n+    }\n+\n+    /**\n+     * Method to randomly place n quantity of moles.\n+     * @param moles quantity of moles to place randomly.\n+     */\n+    void randomPlace(int moles) {\n+        Random random = new Random();\n+        int max = this.moleGrid.length;\n+        int min = 0;\n+        boolean moleIsPlaced;\n+        int limitGrid = this.moleGrid.length * this.moleGrid.length;\n+        if (moles <= limitGrid) {\n+            while (moles > 0) {\n+                int x = random.nextInt(max - min);\n+                int y = random.nextInt(max - min);\n+                moleIsPlaced = place(x, y);\n+                if (moleIsPlaced) {\n+                    moles--;\n+                }\n+            }\n+        }\n+        LOGGER.log(Level.WARNING, \"Is not possible place more than {0} moles \", limitGrid);\n+    }\n+\n+    /**\n+     * Method to whack a location in order to search a mole.\n+     * @param x x location of grid game.\n+     * @param y y location of grid game\n+     */\n+    void whack(int x, int y) {\n+        if (validatedCoordinates(x, y)) {\n+            if (this.moleGrid[x][y] == MOLE) {\n+                LOGGER.log(Level.FINE, \"Good, you found a mole!!\");\n+                this.molesLeft--;\n+                this.score++;\n+\n+                this.trackerMoleGrid[x][y] = WHACKED;\n+                this.moleGrid[x][y] = WHACKED;\n+            }\n+            this.attemptsLeft--;\n+            verifyGameStatus();\n+        }\n+    }\n+\n+    /**\n+     * Method to print the grid available for user.\n+     */\n+    void printGridToUser() {\n+        String gridPrintFormat = Arrays.deepToString(this.trackerMoleGrid);\n+        LOGGER.log(Level.INFO, gridPrintFormat);\n+    }\n+\n+    /**\n+     * Method to print the complete grid game status.\n+     */\n+    void printGrid() {\n+        String gridPrintFormat = Arrays.deepToString(this.moleGrid);\n+        LOGGER.log(Level.INFO, gridPrintFormat);\n+    }\n+\n+    /**\n+     * Method to validate locations.\n+     * @param x x location of grid game.\n+     * @param y y location of grid game.\n+     * @return true, if locations are valid.\n+     *         false, if location are not valid.\n+     */\n+    boolean validatedCoordinates(int x, int y) {\n+        if (x > INVALID_RANGE && y > INVALID_RANGE && x < this.moleGrid.length && y < this.moleGrid.length) {\n+            if (x == -1 && y == -1) {\n+                this.attemptsLeft = 0;\n+                verifyGameStatus();\n+                return false;\n+            }\n+            return true;\n+        } else {","path":"src/main/java/org/minions/devfund/damianvp/WhackAMole.java","position":139,"original_position":139,"commit_id":"3a7b7c6043d72c9ac97176f83bc5ebc0fd06e372","original_commit_id":"3a7b7c6043d72c9ac97176f83bc5ebc0fd06e372","user":{"login":"sphinix27","id":12613518,"node_id":"MDQ6VXNlcjEyNjEzNTE4","avatar_url":"https://avatars2.githubusercontent.com/u/12613518?v=4","gravatar_id":"","url":"https://api.github.com/users/sphinix27","html_url":"https://github.com/sphinix27","followers_url":"https://api.github.com/users/sphinix27/followers","following_url":"https://api.github.com/users/sphinix27/following{/other_user}","gists_url":"https://api.github.com/users/sphinix27/gists{/gist_id}","starred_url":"https://api.github.com/users/sphinix27/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sphinix27/subscriptions","organizations_url":"https://api.github.com/users/sphinix27/orgs","repos_url":"https://api.github.com/users/sphinix27/repos","events_url":"https://api.github.com/users/sphinix27/events{/privacy}","received_events_url":"https://api.github.com/users/sphinix27/received_events","type":"User","site_admin":false},"body":"You can remove the else and just put the Logger and return false after the if condition.","created_at":"2018-07-26T12:09:28Z","updated_at":"2018-07-26T12:11:54Z","html_url":"https://github.com/MinionsGroup/devfund-h/pull/42#discussion_r205431213","pull_request_url":"https://api.github.com/repos/MinionsGroup/devfund-h/pulls/42","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/MinionsGroup/devfund-h/pulls/comments/205431213"},"html":{"href":"https://github.com/MinionsGroup/devfund-h/pull/42#discussion_r205431213"},"pull_request":{"href":"https://api.github.com/repos/MinionsGroup/devfund-h/pulls/42"}}},"pull_request":{"url":"https://api.github.com/repos/MinionsGroup/devfund-h/pulls/42","id":202993098,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAyOTkzMDk4","html_url":"https://github.com/MinionsGroup/devfund-h/pull/42","diff_url":"https://github.com/MinionsGroup/devfund-h/pull/42.diff","patch_url":"https://github.com/MinionsGroup/devfund-h/pull/42.patch","issue_url":"https://api.github.com/repos/MinionsGroup/devfund-h/issues/42","number":42,"state":"open","locked":false,"title":"Damianvp/whack a mole","user":{"login":"Dam24","id":13631177,"node_id":"MDQ6VXNlcjEzNjMxMTc3","avatar_url":"https://avatars2.githubusercontent.com/u/13631177?v=4","gravatar_id":"","url":"https://api.github.com/users/Dam24","html_url":"https://github.com/Dam24","followers_url":"https://api.github.com/users/Dam24/followers","following_url":"https://api.github.com/users/Dam24/following{/other_user}","gists_url":"https://api.github.com/users/Dam24/gists{/gist_id}","starred_url":"https://api.github.com/users/Dam24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dam24/subscriptions","organizations_url":"https://api.github.com/users/Dam24/orgs","repos_url":"https://api.github.com/users/Dam24/repos","events_url":"https://api.github.com/users/Dam24/events{/privacy}","received_events_url":"https://api.github.com/users/Dam24/received_events","type":"User","site_admin":false},"body":"Whack a Mole game task","created_at":"2018-07-21T05:05:48Z","updated_at":"2018-07-26T12:11:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7346cef6edfd2b6736cde4aab156f5f033d72608","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/MinionsGroup/devfund-h/pulls/42/commits","review_comments_url":"https://api.github.com/repos/MinionsGroup/devfund-h/pulls/42/comments","review_comment_url":"https://api.github.com/repos/MinionsGroup/devfund-h/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MinionsGroup/devfund-h/issues/42/comments","statuses_url":"https://api.github.com/repos/MinionsGroup/devfund-h/statuses/3a7b7c6043d72c9ac97176f83bc5ebc0fd06e372","head":{"label":"MinionsGroup:damianvp/WhackAMole","ref":"damianvp/WhackAMole","sha":"3a7b7c6043d72c9ac97176f83bc5ebc0fd06e372","user":{"login":"MinionsGroup","id":38253777,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4MjUzNzc3","avatar_url":"https://avatars2.githubusercontent.com/u/38253777?v=4","gravatar_id":"","url":"https://api.github.com/users/MinionsGroup","html_url":"https://github.com/MinionsGroup","followers_url":"https://api.github.com/users/MinionsGroup/followers","following_url":"https://api.github.com/users/MinionsGroup/following{/other_user}","gists_url":"https://api.github.com/users/MinionsGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/MinionsGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MinionsGroup/subscriptions","organizations_url":"https://api.github.com/users/MinionsGroup/orgs","repos_url":"https://api.github.com/users/MinionsGroup/repos","events_url":"https://api.github.com/users/MinionsGroup/events{/privacy}","received_events_url":"https://api.github.com/users/MinionsGroup/received_events","type":"Organization","site_admin":false},"repo":{"id":139185720,"node_id":"MDEwOlJlcG9zaXRvcnkxMzkxODU3MjA=","name":"devfund-h","full_name":"MinionsGroup/devfund-h","owner":{"login":"MinionsGroup","id":38253777,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4MjUzNzc3","avatar_url":"https://avatars2.githubusercontent.com/u/38253777?v=4","gravatar_id":"","url":"https://api.github.com/users/MinionsGroup","html_url":"https://github.com/MinionsGroup","followers_url":"https://api.github.com/users/MinionsGroup/followers","following_url":"https://api.github.com/users/MinionsGroup/following{/other_user}","gists_url":"https://api.github.com/users/MinionsGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/MinionsGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MinionsGroup/subscriptions","organizations_url":"https://api.github.com/users/MinionsGroup/orgs","repos_url":"https://api.github.com/users/MinionsGroup/repos","events_url":"https://api.github.com/users/MinionsGroup/events{/privacy}","received_events_url":"https://api.github.com/users/MinionsGroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MinionsGroup/devfund-h","description":null,"fork":false,"url":"https://api.github.com/repos/MinionsGroup/devfund-h","forks_url":"https://api.github.com/repos/MinionsGroup/devfund-h/forks","keys_url":"https://api.github.com/repos/MinionsGroup/devfund-h/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MinionsGroup/devfund-h/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MinionsGroup/devfund-h/teams","hooks_url":"https://api.github.com/repos/MinionsGroup/devfund-h/hooks","issue_events_url":"https://api.github.com/repos/MinionsGroup/devfund-h/issues/events{/number}","events_url":"https://api.github.com/repos/MinionsGroup/devfund-h/events","assignees_url":"https://api.github.com/repos/MinionsGroup/devfund-h/assignees{/user}","branches_url":"https://api.github.com/repos/MinionsGroup/devfund-h/branches{/branch}","tags_url":"https://api.github.com/repos/MinionsGroup/devfund-h/tags","blobs_url":"https://api.github.com/repos/MinionsGroup/devfund-h/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MinionsGroup/devfund-h/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MinionsGroup/devfund-h/git/refs{/sha}","trees_url":"https://api.github.com/repos/MinionsGroup/devfund-h/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MinionsGroup/devfund-h/statuses/{sha}","languages_url":"https://api.github.com/repos/MinionsGroup/devfund-h/languages","stargazers_url":"https://api.github.com/repos/MinionsGroup/devfund-h/stargazers","contributors_url":"https://api.github.com/repos/MinionsGroup/devfund-h/contributors","subscribers_url":"https://api.github.com/repos/MinionsGroup/devfund-h/subscribers","subscription_url":"https://api.github.com/repos/MinionsGroup/devfund-h/subscription","commits_url":"https://api.github.com/repos/MinionsGroup/devfund-h/commits{/sha}","git_commits_url":"https://api.github.com/repos/MinionsGroup/devfund-h/git/commits{/sha}","comments_url":"https://api.github.com/repos/MinionsGroup/devfund-h/comments{/number}","issue_comment_url":"https://api.github.com/repos/MinionsGroup/devfund-h/issues/comments{/number}","contents_url":"https://api.github.com/repos/MinionsGroup/devfund-h/contents/{+path}","compare_url":"https://api.github.com/repos/MinionsGroup/devfund-h/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MinionsGroup/devfund-h/merges","archive_url":"https://api.github.com/repos/MinionsGroup/devfund-h/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MinionsGroup/devfund-h/downloads","issues_url":"https://api.github.com/repos/MinionsGroup/devfund-h/issues{/number}","pulls_url":"https://api.github.com/repos/MinionsGroup/devfund-h/pulls{/number}","milestones_url":"https://api.github.com/repos/MinionsGroup/devfund-h/milestones{/number}","notifications_url":"https://api.github.com/repos/MinionsGroup/devfund-h/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MinionsGroup/devfund-h/labels{/name}","releases_url":"https://api.github.com/repos/MinionsGroup/devfund-h/releases{/id}","deployments_url":"https://api.github.com/repos/MinionsGroup/devfund-h/deployments","created_at":"2018-06-29T19:02:39Z","updated_at":"2018-07-25T15:58:53Z","pushed_at":"2018-07-26T06:46:46Z","git_url":"git://github.com/MinionsGroup/devfund-h.git","ssh_url":"git@github.com:MinionsGroup/devfund-h.git","clone_url":"https://github.com/MinionsGroup/devfund-h.git","svn_url":"https://github.com/MinionsGroup/devfund-h","homepage":null,"size":210,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":13,"license":null,"forks":0,"open_issues":13,"watchers":0,"default_branch":"develop"}},"base":{"label":"MinionsGroup:develop","ref":"develop","sha":"3ef52d0bc9fd2179f92011e276ba4963be296774","user":{"login":"MinionsGroup","id":38253777,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4MjUzNzc3","avatar_url":"https://avatars2.githubusercontent.com/u/38253777?v=4","gravatar_id":"","url":"https://api.github.com/users/MinionsGroup","html_url":"https://github.com/MinionsGroup","followers_url":"https://api.github.com/users/MinionsGroup/followers","following_url":"https://api.github.com/users/MinionsGroup/following{/other_user}","gists_url":"https://api.github.com/users/MinionsGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/MinionsGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MinionsGroup/subscriptions","organizations_url":"https://api.github.com/users/MinionsGroup/orgs","repos_url":"https://api.github.com/users/MinionsGroup/repos","events_url":"https://api.github.com/users/MinionsGroup/events{/privacy}","received_events_url":"https://api.github.com/users/MinionsGroup/received_events","type":"Organization","site_admin":false},"repo":{"id":139185720,"node_id":"MDEwOlJlcG9zaXRvcnkxMzkxODU3MjA=","name":"devfund-h","full_name":"MinionsGroup/devfund-h","owner":{"login":"MinionsGroup","id":38253777,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4MjUzNzc3","avatar_url":"https://avatars2.githubusercontent.com/u/38253777?v=4","gravatar_id":"","url":"https://api.github.com/users/MinionsGroup","html_url":"https://github.com/MinionsGroup","followers_url":"https://api.github.com/users/MinionsGroup/followers","following_url":"https://api.github.com/users/MinionsGroup/following{/other_user}","gists_url":"https://api.github.com/users/MinionsGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/MinionsGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MinionsGroup/subscriptions","organizations_url":"https://api.github.com/users/MinionsGroup/orgs","repos_url":"https://api.github.com/users/MinionsGroup/repos","events_url":"https://api.github.com/users/MinionsGroup/events{/privacy}","received_events_url":"https://api.github.com/users/MinionsGroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MinionsGroup/devfund-h","description":null,"fork":false,"url":"https://api.github.com/repos/MinionsGroup/devfund-h","forks_url":"https://api.github.com/repos/MinionsGroup/devfund-h/forks","keys_url":"https://api.github.com/repos/MinionsGroup/devfund-h/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MinionsGroup/devfund-h/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MinionsGroup/devfund-h/teams","hooks_url":"https://api.github.com/repos/MinionsGroup/devfund-h/hooks","issue_events_url":"https://api.github.com/repos/MinionsGroup/devfund-h/issues/events{/number}","events_url":"https://api.github.com/repos/MinionsGroup/devfund-h/events","assignees_url":"https://api.github.com/repos/MinionsGroup/devfund-h/assignees{/user}","branches_url":"https://api.github.com/repos/MinionsGroup/devfund-h/branches{/branch}","tags_url":"https://api.github.com/repos/MinionsGroup/devfund-h/tags","blobs_url":"https://api.github.com/repos/MinionsGroup/devfund-h/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MinionsGroup/devfund-h/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MinionsGroup/devfund-h/git/refs{/sha}","trees_url":"https://api.github.com/repos/MinionsGroup/devfund-h/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MinionsGroup/devfund-h/statuses/{sha}","languages_url":"https://api.github.com/repos/MinionsGroup/devfund-h/languages","stargazers_url":"https://api.github.com/repos/MinionsGroup/devfund-h/stargazers","contributors_url":"https://api.github.com/repos/MinionsGroup/devfund-h/contributors","subscribers_url":"https://api.github.com/repos/MinionsGroup/devfund-h/subscribers","subscription_url":"https://api.github.com/repos/MinionsGroup/devfund-h/subscription","commits_url":"https://api.github.com/repos/MinionsGroup/devfund-h/commits{/sha}","git_commits_url":"https://api.github.com/repos/MinionsGroup/devfund-h/git/commits{/sha}","comments_url":"https://api.github.com/repos/MinionsGroup/devfund-h/comments{/number}","issue_comment_url":"https://api.github.com/repos/MinionsGroup/devfund-h/issues/comments{/number}","contents_url":"https://api.github.com/repos/MinionsGroup/devfund-h/contents/{+path}","compare_url":"https://api.github.com/repos/MinionsGroup/devfund-h/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MinionsGroup/devfund-h/merges","archive_url":"https://api.github.com/repos/MinionsGroup/devfund-h/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MinionsGroup/devfund-h/downloads","issues_url":"https://api.github.com/repos/MinionsGroup/devfund-h/issues{/number}","pulls_url":"https://api.github.com/repos/MinionsGroup/devfund-h/pulls{/number}","milestones_url":"https://api.github.com/repos/MinionsGroup/devfund-h/milestones{/number}","notifications_url":"https://api.github.com/repos/MinionsGroup/devfund-h/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MinionsGroup/devfund-h/labels{/name}","releases_url":"https://api.github.com/repos/MinionsGroup/devfund-h/releases{/id}","deployments_url":"https://api.github.com/repos/MinionsGroup/devfund-h/deployments","created_at":"2018-06-29T19:02:39Z","updated_at":"2018-07-25T15:58:53Z","pushed_at":"2018-07-26T06:46:46Z","git_url":"git://github.com/MinionsGroup/devfund-h.git","ssh_url":"git@github.com:MinionsGroup/devfund-h.git","clone_url":"https://github.com/MinionsGroup/devfund-h.git","svn_url":"https://github.com/MinionsGroup/devfund-h","homepage":null,"size":210,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":13,"license":null,"forks":0,"open_issues":13,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/MinionsGroup/devfund-h/pulls/42"},"html":{"href":"https://github.com/MinionsGroup/devfund-h/pull/42"},"issue":{"href":"https://api.github.com/repos/MinionsGroup/devfund-h/issues/42"},"comments":{"href":"https://api.github.com/repos/MinionsGroup/devfund-h/issues/42/comments"},"review_comments":{"href":"https://api.github.com/repos/MinionsGroup/devfund-h/pulls/42/comments"},"review_comment":{"href":"https://api.github.com/repos/MinionsGroup/devfund-h/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MinionsGroup/devfund-h/pulls/42/commits"},"statuses":{"href":"https://api.github.com/repos/MinionsGroup/devfund-h/statuses/3a7b7c6043d72c9ac97176f83bc5ebc0fd06e372"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"sphinix27"}}