{"action":"created","comment":{"url":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/comments/43616206","id":43616206,"diff_hunk":"@@ -0,0 +1,197 @@\n+package com.bigz.calc;\n+\n+import android.os.Bundle;\n+import android.app.Activity;\n+import android.view.View;\n+import android.widget.TextView;\n+import android.widget.Toast;\n+\n+import java.math.BigInteger;\n+import java.util.HashMap;\n+import java.util.Stack;\n+\n+public class MainActivity extends Activity {\n+\n+    private TextView wind;\n+    private Stack st = new Stack();\n+    private String cur;\n+    private HashMap<Integer, String> num = new HashMap<>();\n+    private HashMap<Integer, BinOp> bop = new HashMap<>();\n+    private HashMap<Integer, UnOp> uop = new HashMap<>();\n+    private double t;\n+    private boolean bad;\n+    private BinOp op;\n+\n+    enum BinOp {\n+        MUL, DIV, ADD, SUB, NONE\n+    }\n+\n+    enum UnOp {\n+        SQRT, UMIN\n+    }\n+\n+\n+    @Override\n+    protected void onCreate(Bundle savedInstanceState) {\n+        super.onCreate(savedInstanceState);\n+        setContentView(R.layout.activity_main);\n+        wind = (TextView) findViewById(R.id.textView);\n+        num.put(R.id.button0, \"0\");\n+        num.put(R.id.button1, \"1\");\n+        num.put(R.id.button2, \"2\");\n+        num.put(R.id.button3, \"3\");\n+        num.put(R.id.button4, \"4\");\n+        num.put(R.id.button5, \"5\");\n+        num.put(R.id.button6, \"6\");\n+        num.put(R.id.button7, \"7\");\n+        num.put(R.id.button8, \"8\");\n+        num.put(R.id.button9, \"9\");\n+        num.put(R.id.button00, \"00\");\n+        bop.put(R.id.buttonDiv, BinOp.DIV);\n+        bop.put(R.id.buttonMul, BinOp.MUL);\n+        bop.put(R.id.buttonAdd, BinOp.ADD);\n+        bop.put(R.id.buttonSub, BinOp.SUB);\n+        uop.put(R.id.buttonSQRT, UnOp.SQRT);\n+        uop.put(R.id.buttonUm, UnOp.UMIN);\n+        cur = \"0\";\n+        op = BinOp.NONE;\n+        bad = false;\n+        wind.setText(cur);\n+        t = 0;\n+    }\n+\n+    public void clickNum(View v) {\n+        try {\n+            t = Double.parseDouble(cur);\n+        } catch (Exception e) {\n+            if (cur.length() != 0) bad = true;\n+        }\n+        if (cur.equals(\"0\")) cur = \"\";\n+        if (num.containsKey(v.getId()) && !bad) {\n+            if ((v.getId() == R.id.button00) && (cur.length() == 0)) {\n+                cur = \"0\";\n+            } else cur += num.get(v.getId());\n+        } else if (v.getId() == R.id.buttonPoint && !bad) {\n+            if (!cur.contains(\".\")) {\n+                if (cur.length() == 0) {\n+                    cur += \"0\";\n+                }\n+                cur += \".\";\n+            }\n+        } else if (v.getId() == R.id.buttonC) {\n+            cur = \"0\";\n+            st.clear();\n+            bad = false;\n+            t = 0;\n+        }\n+        wind.setText(cur);\n+    }\n+\n+    public void clickOp(View v) {\n+        if (cur.length() != 0) {\n+            try {\n+                t = Double.parseDouble(cur);\n+            } catch (Exception e) {\n+                wind.setText(\"Очень жаль\");\n+                Toast.makeText(this, \"Очень жаль\", Toast.LENGTH_SHORT).show();\n+                return;\n+            }\n+        }\n+        if (v.getId() != R.id.buttonE) cur = \"\";\n+        if (v.getId() == R.id.buttonE && !bad) {\n+            if (st.size() == 1) {\n+                st.push(t);\n+                binOp();\n+                cur = print((double) st.peek());\n+                cur = (cur.equals(\"NaN\") ? \"Не число\" : (cur.equals(\"Infinity\") ? \"Ошибка\" : cur));\n+                wind.setText(cur);\n+            }\n+\n+        } else if (bop.containsKey(v.getId()) && !bad) {\n+            st.push(t);\n+            if (st.size() == 2) {\n+                binOp();\n+            }\n+            op = bop.get(v.getId());\n+        } else if (uop.containsKey(v.getId()) && !bad) {\n+            t = unOp(uop.get(v.getId()));\n+            cur = print(t);\n+            wind.setText(cur = (cur.equals(\"NaN\") ? \"Не число\" : cur));\n+        }\n+    }\n+\n+    private double unOp(UnOp o) {\n+        switch (o) {\n+            case SQRT: {\n+                return Math.sqrt(t);\n+            }\n+            case UMIN: {\n+                return ((Math.abs(t - 0) < 0.00000000001) ? 0 : t * (-1));","path":"app/src/main/java/com/bigz/calc/MainActivity.java","position":129,"original_position":129,"commit_id":"7ace409bc25123904f11d4ffd1e64b7c5628214f","original_commit_id":"7ace409bc25123904f11d4ffd1e64b7c5628214f","user":{"login":"HighFlyer13","id":2953187,"avatar_url":"https://avatars.githubusercontent.com/u/2953187?v=3","gravatar_id":"","url":"https://api.github.com/users/HighFlyer13","html_url":"https://github.com/HighFlyer13","followers_url":"https://api.github.com/users/HighFlyer13/followers","following_url":"https://api.github.com/users/HighFlyer13/following{/other_user}","gists_url":"https://api.github.com/users/HighFlyer13/gists{/gist_id}","starred_url":"https://api.github.com/users/HighFlyer13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HighFlyer13/subscriptions","organizations_url":"https://api.github.com/users/HighFlyer13/orgs","repos_url":"https://api.github.com/users/HighFlyer13/repos","events_url":"https://api.github.com/users/HighFlyer13/events{/privacy}","received_events_url":"https://api.github.com/users/HighFlyer13/received_events","type":"User","site_admin":false},"body":"Напрашивается использование BigDecimal?","created_at":"2015-11-02T10:53:00Z","updated_at":"2015-11-02T10:53:00Z","html_url":"https://github.com/IFMO-Android-2015/homework1/pull/2#discussion_r43616206","pull_request_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/comments/43616206"},"html":{"href":"https://github.com/IFMO-Android-2015/homework1/pull/2#discussion_r43616206"},"pull_request":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/2","id":49377902,"html_url":"https://github.com/IFMO-Android-2015/homework1/pull/2","diff_url":"https://github.com/IFMO-Android-2015/homework1/pull/2.diff","patch_url":"https://github.com/IFMO-Android-2015/homework1/pull/2.patch","issue_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/issues/2","number":2,"state":"open","locked":false,"title":"Done","user":{"login":"Kirik64rus","id":12394753,"avatar_url":"https://avatars.githubusercontent.com/u/12394753?v=3","gravatar_id":"","url":"https://api.github.com/users/Kirik64rus","html_url":"https://github.com/Kirik64rus","followers_url":"https://api.github.com/users/Kirik64rus/followers","following_url":"https://api.github.com/users/Kirik64rus/following{/other_user}","gists_url":"https://api.github.com/users/Kirik64rus/gists{/gist_id}","starred_url":"https://api.github.com/users/Kirik64rus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kirik64rus/subscriptions","organizations_url":"https://api.github.com/users/Kirik64rus/orgs","repos_url":"https://api.github.com/users/Kirik64rus/repos","events_url":"https://api.github.com/users/Kirik64rus/events{/privacy}","received_events_url":"https://api.github.com/users/Kirik64rus/received_events","type":"User","site_admin":false},"body":"Zemskov Kirill M3238","created_at":"2015-11-01T18:52:32Z","updated_at":"2015-11-02T10:53:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f55923a73253b0d190810c00fffd062bf617a3f5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/2/commits","review_comments_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/2/comments","review_comment_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/comments{/number}","comments_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/issues/2/comments","statuses_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/statuses/7ace409bc25123904f11d4ffd1e64b7c5628214f","head":{"label":"Kirik64rus:master","ref":"master","sha":"7ace409bc25123904f11d4ffd1e64b7c5628214f","user":{"login":"Kirik64rus","id":12394753,"avatar_url":"https://avatars.githubusercontent.com/u/12394753?v=3","gravatar_id":"","url":"https://api.github.com/users/Kirik64rus","html_url":"https://github.com/Kirik64rus","followers_url":"https://api.github.com/users/Kirik64rus/followers","following_url":"https://api.github.com/users/Kirik64rus/following{/other_user}","gists_url":"https://api.github.com/users/Kirik64rus/gists{/gist_id}","starred_url":"https://api.github.com/users/Kirik64rus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kirik64rus/subscriptions","organizations_url":"https://api.github.com/users/Kirik64rus/orgs","repos_url":"https://api.github.com/users/Kirik64rus/repos","events_url":"https://api.github.com/users/Kirik64rus/events{/privacy}","received_events_url":"https://api.github.com/users/Kirik64rus/received_events","type":"User","site_admin":false},"repo":{"id":45344932,"name":"homework1","full_name":"Kirik64rus/homework1","owner":{"login":"Kirik64rus","id":12394753,"avatar_url":"https://avatars.githubusercontent.com/u/12394753?v=3","gravatar_id":"","url":"https://api.github.com/users/Kirik64rus","html_url":"https://github.com/Kirik64rus","followers_url":"https://api.github.com/users/Kirik64rus/followers","following_url":"https://api.github.com/users/Kirik64rus/following{/other_user}","gists_url":"https://api.github.com/users/Kirik64rus/gists{/gist_id}","starred_url":"https://api.github.com/users/Kirik64rus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kirik64rus/subscriptions","organizations_url":"https://api.github.com/users/Kirik64rus/orgs","repos_url":"https://api.github.com/users/Kirik64rus/repos","events_url":"https://api.github.com/users/Kirik64rus/events{/privacy}","received_events_url":"https://api.github.com/users/Kirik64rus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Kirik64rus/homework1","description":"","fork":true,"url":"https://api.github.com/repos/Kirik64rus/homework1","forks_url":"https://api.github.com/repos/Kirik64rus/homework1/forks","keys_url":"https://api.github.com/repos/Kirik64rus/homework1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Kirik64rus/homework1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Kirik64rus/homework1/teams","hooks_url":"https://api.github.com/repos/Kirik64rus/homework1/hooks","issue_events_url":"https://api.github.com/repos/Kirik64rus/homework1/issues/events{/number}","events_url":"https://api.github.com/repos/Kirik64rus/homework1/events","assignees_url":"https://api.github.com/repos/Kirik64rus/homework1/assignees{/user}","branches_url":"https://api.github.com/repos/Kirik64rus/homework1/branches{/branch}","tags_url":"https://api.github.com/repos/Kirik64rus/homework1/tags","blobs_url":"https://api.github.com/repos/Kirik64rus/homework1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Kirik64rus/homework1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Kirik64rus/homework1/git/refs{/sha}","trees_url":"https://api.github.com/repos/Kirik64rus/homework1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Kirik64rus/homework1/statuses/{sha}","languages_url":"https://api.github.com/repos/Kirik64rus/homework1/languages","stargazers_url":"https://api.github.com/repos/Kirik64rus/homework1/stargazers","contributors_url":"https://api.github.com/repos/Kirik64rus/homework1/contributors","subscribers_url":"https://api.github.com/repos/Kirik64rus/homework1/subscribers","subscription_url":"https://api.github.com/repos/Kirik64rus/homework1/subscription","commits_url":"https://api.github.com/repos/Kirik64rus/homework1/commits{/sha}","git_commits_url":"https://api.github.com/repos/Kirik64rus/homework1/git/commits{/sha}","comments_url":"https://api.github.com/repos/Kirik64rus/homework1/comments{/number}","issue_comment_url":"https://api.github.com/repos/Kirik64rus/homework1/issues/comments{/number}","contents_url":"https://api.github.com/repos/Kirik64rus/homework1/contents/{+path}","compare_url":"https://api.github.com/repos/Kirik64rus/homework1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Kirik64rus/homework1/merges","archive_url":"https://api.github.com/repos/Kirik64rus/homework1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Kirik64rus/homework1/downloads","issues_url":"https://api.github.com/repos/Kirik64rus/homework1/issues{/number}","pulls_url":"https://api.github.com/repos/Kirik64rus/homework1/pulls{/number}","milestones_url":"https://api.github.com/repos/Kirik64rus/homework1/milestones{/number}","notifications_url":"https://api.github.com/repos/Kirik64rus/homework1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Kirik64rus/homework1/labels{/name}","releases_url":"https://api.github.com/repos/Kirik64rus/homework1/releases{/id}","created_at":"2015-11-01T15:05:58Z","updated_at":"2015-11-01T18:50:45Z","pushed_at":"2015-11-01T20:15:52Z","git_url":"git://github.com/Kirik64rus/homework1.git","ssh_url":"git@github.com:Kirik64rus/homework1.git","clone_url":"https://github.com/Kirik64rus/homework1.git","svn_url":"https://github.com/Kirik64rus/homework1","homepage":null,"size":0,"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":"IFMO-Android-2015:master","ref":"master","sha":"cdba00f6819b33da0471f8c16e24aa4849063ef0","user":{"login":"IFMO-Android-2015","id":15182437,"avatar_url":"https://avatars.githubusercontent.com/u/15182437?v=3","gravatar_id":"","url":"https://api.github.com/users/IFMO-Android-2015","html_url":"https://github.com/IFMO-Android-2015","followers_url":"https://api.github.com/users/IFMO-Android-2015/followers","following_url":"https://api.github.com/users/IFMO-Android-2015/following{/other_user}","gists_url":"https://api.github.com/users/IFMO-Android-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/IFMO-Android-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IFMO-Android-2015/subscriptions","organizations_url":"https://api.github.com/users/IFMO-Android-2015/orgs","repos_url":"https://api.github.com/users/IFMO-Android-2015/repos","events_url":"https://api.github.com/users/IFMO-Android-2015/events{/privacy}","received_events_url":"https://api.github.com/users/IFMO-Android-2015/received_events","type":"User","site_admin":false},"repo":{"id":45344078,"name":"homework1","full_name":"IFMO-Android-2015/homework1","owner":{"login":"IFMO-Android-2015","id":15182437,"avatar_url":"https://avatars.githubusercontent.com/u/15182437?v=3","gravatar_id":"","url":"https://api.github.com/users/IFMO-Android-2015","html_url":"https://github.com/IFMO-Android-2015","followers_url":"https://api.github.com/users/IFMO-Android-2015/followers","following_url":"https://api.github.com/users/IFMO-Android-2015/following{/other_user}","gists_url":"https://api.github.com/users/IFMO-Android-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/IFMO-Android-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IFMO-Android-2015/subscriptions","organizations_url":"https://api.github.com/users/IFMO-Android-2015/orgs","repos_url":"https://api.github.com/users/IFMO-Android-2015/repos","events_url":"https://api.github.com/users/IFMO-Android-2015/events{/privacy}","received_events_url":"https://api.github.com/users/IFMO-Android-2015/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/IFMO-Android-2015/homework1","description":"","fork":false,"url":"https://api.github.com/repos/IFMO-Android-2015/homework1","forks_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/forks","keys_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/teams","hooks_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/hooks","issue_events_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/issues/events{/number}","events_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/events","assignees_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/assignees{/user}","branches_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/branches{/branch}","tags_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/tags","blobs_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/git/refs{/sha}","trees_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/statuses/{sha}","languages_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/languages","stargazers_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/stargazers","contributors_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/contributors","subscribers_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/subscribers","subscription_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/subscription","commits_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/commits{/sha}","git_commits_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/git/commits{/sha}","comments_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/comments{/number}","issue_comment_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/issues/comments{/number}","contents_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/contents/{+path}","compare_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/merges","archive_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/downloads","issues_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/issues{/number}","pulls_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls{/number}","milestones_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/milestones{/number}","notifications_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/labels{/name}","releases_url":"https://api.github.com/repos/IFMO-Android-2015/homework1/releases{/id}","created_at":"2015-11-01T14:43:27Z","updated_at":"2015-11-01T14:43:27Z","pushed_at":"2015-11-02T07:32:47Z","git_url":"git://github.com/IFMO-Android-2015/homework1.git","ssh_url":"git@github.com:IFMO-Android-2015/homework1.git","clone_url":"https://github.com/IFMO-Android-2015/homework1.git","svn_url":"https://github.com/IFMO-Android-2015/homework1","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":7,"forks":11,"open_issues":7,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/2"},"html":{"href":"https://github.com/IFMO-Android-2015/homework1/pull/2"},"issue":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/issues/2"},"comments":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/IFMO-Android-2015/homework1/statuses/7ace409bc25123904f11d4ffd1e64b7c5628214f"}}}}