{"action":"created","comment":{"url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/comments/83539434","pull_request_review_id":4378959,"id":83539434,"diff_hunk":"@@ -0,0 +1,71 @@\n+package ru.mipt.java2016.homework.g597.markov;\n+/**\n+ * Created by Alexander on 08.10.2016.\n+ */\n+\n+\n+import ru.mipt.java2016.homework.base.task1.Calculator;\n+import ru.mipt.java2016.homework.base.task1.ParsingException;\n+\n+import java.util.Stack;\n+import java.util.StringTokenizer;\n+import java.util.regex.Matcher;\n+import java.util.regex.Pattern;\n+\n+\n+public class MyCalculator implements Calculator {\n+\n+    private static String markUnaryOperations(String s, char newSymbolMinus, char newSymbolPlus) throws ParsingException {\n+        String result = \"(\";\n+        String correctSymbols = \"01234567890.+-*/()\";\n+        for (int i = 1; i < s.length(); i++) {\n+            char current = s.charAt(i);\n+            char previous = s.charAt(i - 1);\n+            if (correctSymbols.indexOf(current) == -1)\n+                throw new ParsingException(\"Incorrect symbol in equation\");\n+            if (current == ')' && previous == '(')\n+                throw new ParsingException(\"Empty parenthesis\");\n+            if (current == '-' && previous != ')' && !Character.isDigit(previous))\n+                current = newSymbolMinus;\n+            if (current == '+' && previous != ')' && !Character.isDigit(previous))\n+                current = newSymbolPlus;\n+            result = result + current;\n+        }\n+        return result;\n+    }\n+\n+    public double calculate(String inputString) throws ParsingException {\n+        if (inputString == null) {\n+            throw new ParsingException(\"Null expression\");\n+        }\n+        if (!validateString(inputString)) {\n+            throw new ParsingException(\"Incorrect input\");\n+        }\n+        inputString = \"(\" + inputString.replaceAll(\"\\\\s\", \"\") + \")\";\n+        inputString = markUnaryOperations(inputString, '~', '#');\n+        StringTokenizer tokenizer = new StringTokenizer(inputString, \"+-*/()~#\", true);\n+        Stack<NumberLexeme> results = new Stack<NumberLexeme>();\n+        Stack<Lexeme> operations = new Stack<Lexeme>();\n+        while (tokenizer.hasMoreTokens()) {\n+            String t = tokenizer.nextToken();","path":"homework-g597-MARKOV/src/main/java/ru/mipt/java2016/homework/g597/markov/MyCalculator.java","position":50,"original_position":50,"commit_id":"0928758aaeab2654e7e127c38e2136f0e6f6a849","original_commit_id":"0928758aaeab2654e7e127c38e2136f0e6f6a849","user":{"login":"ignorer","id":4057463,"avatar_url":"https://avatars.githubusercontent.com/u/4057463?v=3","gravatar_id":"","url":"https://api.github.com/users/ignorer","html_url":"https://github.com/ignorer","followers_url":"https://api.github.com/users/ignorer/followers","following_url":"https://api.github.com/users/ignorer/following{/other_user}","gists_url":"https://api.github.com/users/ignorer/gists{/gist_id}","starred_url":"https://api.github.com/users/ignorer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ignorer/subscriptions","organizations_url":"https://api.github.com/users/ignorer/orgs","repos_url":"https://api.github.com/users/ignorer/repos","events_url":"https://api.github.com/users/ignorer/events{/privacy}","received_events_url":"https://api.github.com/users/ignorer/received_events","type":"User","site_admin":false},"body":"Ну уж без строки, названной одной буквой, можно, наверное, как-нибудь обойтись. Она всего в одном месте используется, подставил бы туда сразу `tokenizer.nextToken()`","created_at":"2016-10-15T20:16:38Z","updated_at":"2016-10-15T20:16:39Z","html_url":"https://github.com/fediq/mipt-java-2016/pull/14#discussion_r83539434","pull_request_url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/comments/83539434"},"html":{"href":"https://github.com/fediq/mipt-java-2016/pull/14#discussion_r83539434"},"pull_request":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/14","id":88613885,"html_url":"https://github.com/fediq/mipt-java-2016/pull/14","diff_url":"https://github.com/fediq/mipt-java-2016/pull/14.diff","patch_url":"https://github.com/fediq/mipt-java-2016/pull/14.patch","issue_url":"https://api.github.com/repos/fediq/mipt-java-2016/issues/14","number":14,"state":"open","locked":false,"title":"Update from original","user":{"login":"markovalexander","id":22663468,"avatar_url":"https://avatars.githubusercontent.com/u/22663468?v=3","gravatar_id":"","url":"https://api.github.com/users/markovalexander","html_url":"https://github.com/markovalexander","followers_url":"https://api.github.com/users/markovalexander/followers","following_url":"https://api.github.com/users/markovalexander/following{/other_user}","gists_url":"https://api.github.com/users/markovalexander/gists{/gist_id}","starred_url":"https://api.github.com/users/markovalexander/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markovalexander/subscriptions","organizations_url":"https://api.github.com/users/markovalexander/orgs","repos_url":"https://api.github.com/users/markovalexander/repos","events_url":"https://api.github.com/users/markovalexander/events{/privacy}","received_events_url":"https://api.github.com/users/markovalexander/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-10T06:19:27Z","updated_at":"2016-10-15T20:16:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/14/commits","review_comments_url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/14/comments","review_comment_url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fediq/mipt-java-2016/issues/14/comments","statuses_url":"https://api.github.com/repos/fediq/mipt-java-2016/statuses/0928758aaeab2654e7e127c38e2136f0e6f6a849","head":{"label":"markovalexander:master","ref":"master","sha":"0928758aaeab2654e7e127c38e2136f0e6f6a849","user":{"login":"markovalexander","id":22663468,"avatar_url":"https://avatars.githubusercontent.com/u/22663468?v=3","gravatar_id":"","url":"https://api.github.com/users/markovalexander","html_url":"https://github.com/markovalexander","followers_url":"https://api.github.com/users/markovalexander/followers","following_url":"https://api.github.com/users/markovalexander/following{/other_user}","gists_url":"https://api.github.com/users/markovalexander/gists{/gist_id}","starred_url":"https://api.github.com/users/markovalexander/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markovalexander/subscriptions","organizations_url":"https://api.github.com/users/markovalexander/orgs","repos_url":"https://api.github.com/users/markovalexander/repos","events_url":"https://api.github.com/users/markovalexander/events{/privacy}","received_events_url":"https://api.github.com/users/markovalexander/received_events","type":"User","site_admin":false},"repo":{"id":70341358,"name":"mipt-java-2016","full_name":"markovalexander/mipt-java-2016","owner":{"login":"markovalexander","id":22663468,"avatar_url":"https://avatars.githubusercontent.com/u/22663468?v=3","gravatar_id":"","url":"https://api.github.com/users/markovalexander","html_url":"https://github.com/markovalexander","followers_url":"https://api.github.com/users/markovalexander/followers","following_url":"https://api.github.com/users/markovalexander/following{/other_user}","gists_url":"https://api.github.com/users/markovalexander/gists{/gist_id}","starred_url":"https://api.github.com/users/markovalexander/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markovalexander/subscriptions","organizations_url":"https://api.github.com/users/markovalexander/orgs","repos_url":"https://api.github.com/users/markovalexander/repos","events_url":"https://api.github.com/users/markovalexander/events{/privacy}","received_events_url":"https://api.github.com/users/markovalexander/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/markovalexander/mipt-java-2016","description":"Практическая часть курса \"Программирование на Java\", 2016 год","fork":true,"url":"https://api.github.com/repos/markovalexander/mipt-java-2016","forks_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/forks","keys_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/keys{/key_id}","collaborators_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/teams","hooks_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/hooks","issue_events_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/issues/events{/number}","events_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/events","assignees_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/assignees{/user}","branches_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/branches{/branch}","tags_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/tags","blobs_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/git/refs{/sha}","trees_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/git/trees{/sha}","statuses_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/statuses/{sha}","languages_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/languages","stargazers_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/stargazers","contributors_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/contributors","subscribers_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/subscribers","subscription_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/subscription","commits_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/commits{/sha}","git_commits_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/git/commits{/sha}","comments_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/comments{/number}","issue_comment_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/issues/comments{/number}","contents_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/contents/{+path}","compare_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/compare/{base}...{head}","merges_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/merges","archive_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/downloads","issues_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/issues{/number}","pulls_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/pulls{/number}","milestones_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/milestones{/number}","notifications_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/labels{/name}","releases_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/releases{/id}","deployments_url":"https://api.github.com/repos/markovalexander/mipt-java-2016/deployments","created_at":"2016-10-08T15:45:24Z","updated_at":"2016-10-08T15:45:25Z","pushed_at":"2016-10-14T15:37:28Z","git_url":"git://github.com/markovalexander/mipt-java-2016.git","ssh_url":"git@github.com:markovalexander/mipt-java-2016.git","clone_url":"https://github.com/markovalexander/mipt-java-2016.git","svn_url":"https://github.com/markovalexander/mipt-java-2016","homepage":null,"size":70,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"fediq:master","ref":"master","sha":"90dd2248e30d0925271d2c5dfad46082e9d9d491","user":{"login":"fediq","id":1057798,"avatar_url":"https://avatars.githubusercontent.com/u/1057798?v=3","gravatar_id":"","url":"https://api.github.com/users/fediq","html_url":"https://github.com/fediq","followers_url":"https://api.github.com/users/fediq/followers","following_url":"https://api.github.com/users/fediq/following{/other_user}","gists_url":"https://api.github.com/users/fediq/gists{/gist_id}","starred_url":"https://api.github.com/users/fediq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fediq/subscriptions","organizations_url":"https://api.github.com/users/fediq/orgs","repos_url":"https://api.github.com/users/fediq/repos","events_url":"https://api.github.com/users/fediq/events{/privacy}","received_events_url":"https://api.github.com/users/fediq/received_events","type":"User","site_admin":false},"repo":{"id":69496783,"name":"mipt-java-2016","full_name":"fediq/mipt-java-2016","owner":{"login":"fediq","id":1057798,"avatar_url":"https://avatars.githubusercontent.com/u/1057798?v=3","gravatar_id":"","url":"https://api.github.com/users/fediq","html_url":"https://github.com/fediq","followers_url":"https://api.github.com/users/fediq/followers","following_url":"https://api.github.com/users/fediq/following{/other_user}","gists_url":"https://api.github.com/users/fediq/gists{/gist_id}","starred_url":"https://api.github.com/users/fediq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fediq/subscriptions","organizations_url":"https://api.github.com/users/fediq/orgs","repos_url":"https://api.github.com/users/fediq/repos","events_url":"https://api.github.com/users/fediq/events{/privacy}","received_events_url":"https://api.github.com/users/fediq/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fediq/mipt-java-2016","description":"Практическая часть курса \"Программирование на Java\", 2016 год","fork":false,"url":"https://api.github.com/repos/fediq/mipt-java-2016","forks_url":"https://api.github.com/repos/fediq/mipt-java-2016/forks","keys_url":"https://api.github.com/repos/fediq/mipt-java-2016/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fediq/mipt-java-2016/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fediq/mipt-java-2016/teams","hooks_url":"https://api.github.com/repos/fediq/mipt-java-2016/hooks","issue_events_url":"https://api.github.com/repos/fediq/mipt-java-2016/issues/events{/number}","events_url":"https://api.github.com/repos/fediq/mipt-java-2016/events","assignees_url":"https://api.github.com/repos/fediq/mipt-java-2016/assignees{/user}","branches_url":"https://api.github.com/repos/fediq/mipt-java-2016/branches{/branch}","tags_url":"https://api.github.com/repos/fediq/mipt-java-2016/tags","blobs_url":"https://api.github.com/repos/fediq/mipt-java-2016/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fediq/mipt-java-2016/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fediq/mipt-java-2016/git/refs{/sha}","trees_url":"https://api.github.com/repos/fediq/mipt-java-2016/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fediq/mipt-java-2016/statuses/{sha}","languages_url":"https://api.github.com/repos/fediq/mipt-java-2016/languages","stargazers_url":"https://api.github.com/repos/fediq/mipt-java-2016/stargazers","contributors_url":"https://api.github.com/repos/fediq/mipt-java-2016/contributors","subscribers_url":"https://api.github.com/repos/fediq/mipt-java-2016/subscribers","subscription_url":"https://api.github.com/repos/fediq/mipt-java-2016/subscription","commits_url":"https://api.github.com/repos/fediq/mipt-java-2016/commits{/sha}","git_commits_url":"https://api.github.com/repos/fediq/mipt-java-2016/git/commits{/sha}","comments_url":"https://api.github.com/repos/fediq/mipt-java-2016/comments{/number}","issue_comment_url":"https://api.github.com/repos/fediq/mipt-java-2016/issues/comments{/number}","contents_url":"https://api.github.com/repos/fediq/mipt-java-2016/contents/{+path}","compare_url":"https://api.github.com/repos/fediq/mipt-java-2016/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fediq/mipt-java-2016/merges","archive_url":"https://api.github.com/repos/fediq/mipt-java-2016/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fediq/mipt-java-2016/downloads","issues_url":"https://api.github.com/repos/fediq/mipt-java-2016/issues{/number}","pulls_url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls{/number}","milestones_url":"https://api.github.com/repos/fediq/mipt-java-2016/milestones{/number}","notifications_url":"https://api.github.com/repos/fediq/mipt-java-2016/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fediq/mipt-java-2016/labels{/name}","releases_url":"https://api.github.com/repos/fediq/mipt-java-2016/releases{/id}","deployments_url":"https://api.github.com/repos/fediq/mipt-java-2016/deployments","created_at":"2016-09-28T19:29:28Z","updated_at":"2016-10-15T08:31:39Z","pushed_at":"2016-10-15T20:11:42Z","git_url":"git://github.com/fediq/mipt-java-2016.git","ssh_url":"git@github.com:fediq/mipt-java-2016.git","clone_url":"https://github.com/fediq/mipt-java-2016.git","svn_url":"https://github.com/fediq/mipt-java-2016","homepage":null,"size":848,"stargazers_count":12,"watchers_count":12,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":83,"mirror_url":null,"open_issues_count":36,"forks":83,"open_issues":36,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/14"},"html":{"href":"https://github.com/fediq/mipt-java-2016/pull/14"},"issue":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/issues/14"},"comments":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/statuses/0928758aaeab2654e7e127c38e2136f0e6f6a849"}}}}
{"actor":{"display_login":"ignorer"}}