{"action":"created","comment":{"url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/comments/48486039","id":48486039,"diff_hunk":"@@ -0,0 +1,235 @@\n+package ru.unn.agile.LongArithmetic.viewmodel;\n+\n+import ru.unn.agile.LongArithmetic.model.LongNumber;\n+import ru.unn.agile.LongArithmetic.model.Matrix;\n+\n+public class ViewModel {\n+\n+    private static final int INITIAL_SIZE_MATRIX = 1;\n+\n+    private String mFirstMatrix;\n+    private String nFirstMatrix;\n+    private String mSecondMatrix;\n+    private String nSecondMatrix;\n+    private int m1;\n+    private int n1;\n+    private int m2;\n+    private int n2;\n+\n+    private String [][] firstMatrixTable;\n+    private String [][] secondMatrixTable;\n+    private Matrix firstMultiplier;\n+    private Matrix secondMultiplier;\n+    private Matrix resultMatrix;\n+\n+    private String status;\n+    private boolean isOkButtonEnabled;\n+    private boolean isMultiplyButtonEnabled;\n+    private boolean isInputMatricesAvailable;\n+\n+\n+    public ViewModel() {\n+        mFirstMatrix = \"\";\n+        nFirstMatrix = \"\";\n+        mSecondMatrix = \"\";\n+        nSecondMatrix = \"\";\n+        status = Status.WAITING_MN;\n+\n+        firstMatrixTable = new String[INITIAL_SIZE_MATRIX][INITIAL_SIZE_MATRIX];\n+        secondMatrixTable = new String[INITIAL_SIZE_MATRIX][INITIAL_SIZE_MATRIX];\n+\n+        isOkButtonEnabled = false;\n+        isMultiplyButtonEnabled = false;\n+        isInputMatricesAvailable = false;\n+    }\n+\n+    public void processingInputMN() {\n+        parseInputMN();\n+        if (isOkButtonEnabled()) {\n+            firstMatrixTable = new String[m1][n1];\n+            secondMatrixTable = new String[m2][n2];\n+            firstMultiplier = new Matrix(m1, n1);\n+            secondMultiplier = new Matrix(m2, n2);\n+            status = Status.WAITING;\n+            isMultiplyButtonEnabled = true;\n+        }\n+    }\n+\n+    public void parseInputMN() {\n+        isMultiplyButtonEnabled = false;\n+\n+        try {\n+            tryParseInputMN();\n+\n+            isOkButtonEnabled = false;\n+            if (isInputMNAvailable() && n1 == m2) {\n+                isOkButtonEnabled = true;\n+            }\n+            if (status != Status.WAITING) {\n+                if (isOkButtonEnabled) {\n+                    status = Status.READY_OK;\n+                } else {\n+                    status = Status.WAITING_MN;\n+                }\n+            }\n+        } catch (Exception e) {\n+            status = Status.BAD_FORMAT;\n+            isOkButtonEnabled = false;\n+        }\n+    }\n+\n+    private void tryParseInputMN() {\n+        if (!mFirstMatrix.isEmpty()) {\n+            m1 = Integer.parseInt(mFirstMatrix);\n+        }\n+        if (!nFirstMatrix.isEmpty()) {\n+            n1 = Integer.parseInt(nFirstMatrix);\n+        }\n+        if (!mSecondMatrix.isEmpty()) {\n+            m2 = Integer.parseInt(mSecondMatrix);\n+        }\n+        if (!nSecondMatrix.isEmpty()) {\n+            n2 = Integer.parseInt(nSecondMatrix);\n+        }\n+    }\n+\n+    public boolean isOkButtonEnabled() { return isOkButtonEnabled; }\n+\n+    private boolean isInputMNAvailable() {\n+        boolean isAvailable = !mFirstMatrix.isEmpty() && !nFirstMatrix.isEmpty()\n+                            && !mSecondMatrix.isEmpty() && !nSecondMatrix.isEmpty();\n+\n+        return isAvailable;\n+    }\n+\n+    public void processingInputMatrices() {\n+        parseInputMatrices();\n+        if (isInputMatricesAvailable()) {\n+            multiplyMatrices();\n+            status = Status.SUCCESS;\n+        }\n+    }\n+\n+    public  void parseInputMatrices() {\n+        if (status == Status.WAITING_MN) {\n+            return;\n+        }\n+\n+        try {\n+            tryParseInputMatrices();\n+            isInputMatricesAvailable = true;\n+            status = Status.READY_MULTIPLY;\n+        } catch (Exception e) {\n+            isInputMatricesAvailable = false;\n+            status = Status.BAD_FORMAT;\n+        }\n+    }\n+\n+    private boolean isInputMatricesAvailable() { return isInputMatricesAvailable; }\n+\n+    private void tryParseInputMatrices() throws Exception {\n+        LongNumber value;\n+        for (int i = 0; i < m1; i++) {\n+            for (int j = 0; j < n1; j++) {\n+                value = new LongNumber(firstMatrixTable[i][j]);\n+                if (value.isUndefined()) {\n+                    throw new Exception(\"Can't parse input matrices, bad format\");\n+                }\n+                firstMultiplier.setElement(i, j, value);\n+            }\n+        }\n+\n+        for (int i = 0; i < m2; i++) {\n+            for (int j = 0; j < n2; j++) {\n+                value = new LongNumber(secondMatrixTable[i][j]);\n+                if (value.isUndefined()) {\n+                    throw new Exception(\"Can't parse input matrices, bad format\");\n+                }\n+                secondMultiplier.setElement(i, j, value);\n+            }\n+        }\n+    }\n+\n+    private void multiplyMatrices() {\n+        if (status == Status.READY_MULTIPLY) {\n+            resultMatrix = firstMultiplier.multiply(secondMultiplier);\n+        }\n+    }\n+\n+    public String getMFirstMatrix() { return mFirstMatrix; }\n+\n+    public void setMFirstMatrix(final String mFirstMatrix) {\n+        if (mFirstMatrix.equals(this.mFirstMatrix)) {\n+            return;\n+        }\n+\n+        this.mFirstMatrix = mFirstMatrix;","path":"code/gatchenko-viktor/ViewModel/src/main/java/ru/unn/agile/LongArithmetic/viewmodel/ViewModel.java","position":166,"original_position":166,"commit_id":"9deaf88180a1a8479f6bd3aa6acaac5e0b38f584","original_commit_id":"9deaf88180a1a8479f6bd3aa6acaac5e0b38f584","user":{"login":"Leon-999","id":4349804,"avatar_url":"https://avatars.githubusercontent.com/u/4349804?v=3","gravatar_id":"","url":"https://api.github.com/users/Leon-999","html_url":"https://github.com/Leon-999","followers_url":"https://api.github.com/users/Leon-999/followers","following_url":"https://api.github.com/users/Leon-999/following{/other_user}","gists_url":"https://api.github.com/users/Leon-999/gists{/gist_id}","starred_url":"https://api.github.com/users/Leon-999/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Leon-999/subscriptions","organizations_url":"https://api.github.com/users/Leon-999/orgs","repos_url":"https://api.github.com/users/Leon-999/repos","events_url":"https://api.github.com/users/Leon-999/events{/privacy}","received_events_url":"https://api.github.com/users/Leon-999/received_events","type":"User","site_admin":false},"body":"fixed","created_at":"2015-12-28T15:42:43Z","updated_at":"2015-12-28T15:42:43Z","html_url":"https://github.com/UNN-VMK-Software/agile-course-practice/pull/185#discussion_r48486039","pull_request_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/185","_links":{"self":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/comments/48486039"},"html":{"href":"https://github.com/UNN-VMK-Software/agile-course-practice/pull/185#discussion_r48486039"},"pull_request":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/185"}}},"pull_request":{"url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/185","id":54621096,"html_url":"https://github.com/UNN-VMK-Software/agile-course-practice/pull/185","diff_url":"https://github.com/UNN-VMK-Software/agile-course-practice/pull/185.diff","patch_url":"https://github.com/UNN-VMK-Software/agile-course-practice/pull/185.patch","issue_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/issues/185","number":185,"state":"open","locked":false,"title":"Гатченко - Лабораторная работа #2","user":{"login":"Leon-999","id":4349804,"avatar_url":"https://avatars.githubusercontent.com/u/4349804?v=3","gravatar_id":"","url":"https://api.github.com/users/Leon-999","html_url":"https://github.com/Leon-999","followers_url":"https://api.github.com/users/Leon-999/followers","following_url":"https://api.github.com/users/Leon-999/following{/other_user}","gists_url":"https://api.github.com/users/Leon-999/gists{/gist_id}","starred_url":"https://api.github.com/users/Leon-999/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Leon-999/subscriptions","organizations_url":"https://api.github.com/users/Leon-999/orgs","repos_url":"https://api.github.com/users/Leon-999/repos","events_url":"https://api.github.com/users/Leon-999/events{/privacy}","received_events_url":"https://api.github.com/users/Leon-999/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-27T17:37:03Z","updated_at":"2015-12-28T15:42:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eff94b22644d757f154c47989272997dff2c90cb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/185/commits","review_comments_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/185/comments","review_comment_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/comments{/number}","comments_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/issues/185/comments","statuses_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/statuses/9deaf88180a1a8479f6bd3aa6acaac5e0b38f584","head":{"label":"Leon-999:gatchenko-viktor-lab2","ref":"gatchenko-viktor-lab2","sha":"9deaf88180a1a8479f6bd3aa6acaac5e0b38f584","user":{"login":"Leon-999","id":4349804,"avatar_url":"https://avatars.githubusercontent.com/u/4349804?v=3","gravatar_id":"","url":"https://api.github.com/users/Leon-999","html_url":"https://github.com/Leon-999","followers_url":"https://api.github.com/users/Leon-999/followers","following_url":"https://api.github.com/users/Leon-999/following{/other_user}","gists_url":"https://api.github.com/users/Leon-999/gists{/gist_id}","starred_url":"https://api.github.com/users/Leon-999/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Leon-999/subscriptions","organizations_url":"https://api.github.com/users/Leon-999/orgs","repos_url":"https://api.github.com/users/Leon-999/repos","events_url":"https://api.github.com/users/Leon-999/events{/privacy}","received_events_url":"https://api.github.com/users/Leon-999/received_events","type":"User","site_admin":false},"repo":{"id":45357845,"name":"agile-course-practice","full_name":"Leon-999/agile-course-practice","owner":{"login":"Leon-999","id":4349804,"avatar_url":"https://avatars.githubusercontent.com/u/4349804?v=3","gravatar_id":"","url":"https://api.github.com/users/Leon-999","html_url":"https://github.com/Leon-999","followers_url":"https://api.github.com/users/Leon-999/followers","following_url":"https://api.github.com/users/Leon-999/following{/other_user}","gists_url":"https://api.github.com/users/Leon-999/gists{/gist_id}","starred_url":"https://api.github.com/users/Leon-999/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Leon-999/subscriptions","organizations_url":"https://api.github.com/users/Leon-999/orgs","repos_url":"https://api.github.com/users/Leon-999/repos","events_url":"https://api.github.com/users/Leon-999/events{/privacy}","received_events_url":"https://api.github.com/users/Leon-999/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Leon-999/agile-course-practice","description":"Проект-шаблон для выполнения лабораторных работ по курсу Agile Development","fork":true,"url":"https://api.github.com/repos/Leon-999/agile-course-practice","forks_url":"https://api.github.com/repos/Leon-999/agile-course-practice/forks","keys_url":"https://api.github.com/repos/Leon-999/agile-course-practice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Leon-999/agile-course-practice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Leon-999/agile-course-practice/teams","hooks_url":"https://api.github.com/repos/Leon-999/agile-course-practice/hooks","issue_events_url":"https://api.github.com/repos/Leon-999/agile-course-practice/issues/events{/number}","events_url":"https://api.github.com/repos/Leon-999/agile-course-practice/events","assignees_url":"https://api.github.com/repos/Leon-999/agile-course-practice/assignees{/user}","branches_url":"https://api.github.com/repos/Leon-999/agile-course-practice/branches{/branch}","tags_url":"https://api.github.com/repos/Leon-999/agile-course-practice/tags","blobs_url":"https://api.github.com/repos/Leon-999/agile-course-practice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Leon-999/agile-course-practice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Leon-999/agile-course-practice/git/refs{/sha}","trees_url":"https://api.github.com/repos/Leon-999/agile-course-practice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Leon-999/agile-course-practice/statuses/{sha}","languages_url":"https://api.github.com/repos/Leon-999/agile-course-practice/languages","stargazers_url":"https://api.github.com/repos/Leon-999/agile-course-practice/stargazers","contributors_url":"https://api.github.com/repos/Leon-999/agile-course-practice/contributors","subscribers_url":"https://api.github.com/repos/Leon-999/agile-course-practice/subscribers","subscription_url":"https://api.github.com/repos/Leon-999/agile-course-practice/subscription","commits_url":"https://api.github.com/repos/Leon-999/agile-course-practice/commits{/sha}","git_commits_url":"https://api.github.com/repos/Leon-999/agile-course-practice/git/commits{/sha}","comments_url":"https://api.github.com/repos/Leon-999/agile-course-practice/comments{/number}","issue_comment_url":"https://api.github.com/repos/Leon-999/agile-course-practice/issues/comments{/number}","contents_url":"https://api.github.com/repos/Leon-999/agile-course-practice/contents/{+path}","compare_url":"https://api.github.com/repos/Leon-999/agile-course-practice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Leon-999/agile-course-practice/merges","archive_url":"https://api.github.com/repos/Leon-999/agile-course-practice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Leon-999/agile-course-practice/downloads","issues_url":"https://api.github.com/repos/Leon-999/agile-course-practice/issues{/number}","pulls_url":"https://api.github.com/repos/Leon-999/agile-course-practice/pulls{/number}","milestones_url":"https://api.github.com/repos/Leon-999/agile-course-practice/milestones{/number}","notifications_url":"https://api.github.com/repos/Leon-999/agile-course-practice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Leon-999/agile-course-practice/labels{/name}","releases_url":"https://api.github.com/repos/Leon-999/agile-course-practice/releases{/id}","created_at":"2015-11-01T21:16:20Z","updated_at":"2015-11-01T21:16:21Z","pushed_at":"2015-12-27T19:13:12Z","git_url":"git://github.com/Leon-999/agile-course-practice.git","ssh_url":"git@github.com:Leon-999/agile-course-practice.git","clone_url":"https://github.com/Leon-999/agile-course-practice.git","svn_url":"https://github.com/Leon-999/agile-course-practice","homepage":"","size":5911,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"UNN-VMK-Software:master","ref":"master","sha":"72bf4d7dfa453bd3ccf6c5870a14cd4a0c5b24c2","user":{"login":"UNN-VMK-Software","id":5463209,"avatar_url":"https://avatars.githubusercontent.com/u/5463209?v=3","gravatar_id":"","url":"https://api.github.com/users/UNN-VMK-Software","html_url":"https://github.com/UNN-VMK-Software","followers_url":"https://api.github.com/users/UNN-VMK-Software/followers","following_url":"https://api.github.com/users/UNN-VMK-Software/following{/other_user}","gists_url":"https://api.github.com/users/UNN-VMK-Software/gists{/gist_id}","starred_url":"https://api.github.com/users/UNN-VMK-Software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UNN-VMK-Software/subscriptions","organizations_url":"https://api.github.com/users/UNN-VMK-Software/orgs","repos_url":"https://api.github.com/users/UNN-VMK-Software/repos","events_url":"https://api.github.com/users/UNN-VMK-Software/events{/privacy}","received_events_url":"https://api.github.com/users/UNN-VMK-Software/received_events","type":"Organization","site_admin":false},"repo":{"id":44518750,"name":"agile-course-practice","full_name":"UNN-VMK-Software/agile-course-practice","owner":{"login":"UNN-VMK-Software","id":5463209,"avatar_url":"https://avatars.githubusercontent.com/u/5463209?v=3","gravatar_id":"","url":"https://api.github.com/users/UNN-VMK-Software","html_url":"https://github.com/UNN-VMK-Software","followers_url":"https://api.github.com/users/UNN-VMK-Software/followers","following_url":"https://api.github.com/users/UNN-VMK-Software/following{/other_user}","gists_url":"https://api.github.com/users/UNN-VMK-Software/gists{/gist_id}","starred_url":"https://api.github.com/users/UNN-VMK-Software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UNN-VMK-Software/subscriptions","organizations_url":"https://api.github.com/users/UNN-VMK-Software/orgs","repos_url":"https://api.github.com/users/UNN-VMK-Software/repos","events_url":"https://api.github.com/users/UNN-VMK-Software/events{/privacy}","received_events_url":"https://api.github.com/users/UNN-VMK-Software/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/UNN-VMK-Software/agile-course-practice","description":"Проект-шаблон для выполнения лабораторных работ по курсу Agile Development","fork":false,"url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice","forks_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/forks","keys_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/teams","hooks_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/hooks","issue_events_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/issues/events{/number}","events_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/events","assignees_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/assignees{/user}","branches_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/branches{/branch}","tags_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/tags","blobs_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/git/refs{/sha}","trees_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/statuses/{sha}","languages_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/languages","stargazers_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/stargazers","contributors_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/contributors","subscribers_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/subscribers","subscription_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/subscription","commits_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/commits{/sha}","git_commits_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/git/commits{/sha}","comments_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/comments{/number}","issue_comment_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/issues/comments{/number}","contents_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/contents/{+path}","compare_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/merges","archive_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/downloads","issues_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/issues{/number}","pulls_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls{/number}","milestones_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/milestones{/number}","notifications_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/labels{/name}","releases_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/releases{/id}","created_at":"2015-10-19T07:42:22Z","updated_at":"2015-10-29T19:46:12Z","pushed_at":"2015-12-27T22:18:47Z","git_url":"git://github.com/UNN-VMK-Software/agile-course-practice.git","ssh_url":"git@github.com:UNN-VMK-Software/agile-course-practice.git","clone_url":"https://github.com/UNN-VMK-Software/agile-course-practice.git","svn_url":"https://github.com/UNN-VMK-Software/agile-course-practice","homepage":"","size":6235,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":46,"mirror_url":null,"open_issues_count":17,"forks":46,"open_issues":17,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/185"},"html":{"href":"https://github.com/UNN-VMK-Software/agile-course-practice/pull/185"},"issue":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/issues/185"},"comments":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/issues/185/comments"},"review_comments":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/185/comments"},"review_comment":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/185/commits"},"statuses":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/statuses/9deaf88180a1a8479f6bd3aa6acaac5e0b38f584"}}}}