{"action":"created","comment":{"url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/pulls/comments/89623361","pull_request_review_id":10163402,"id":89623361,"diff_hunk":"@@ -38,32 +41,62 @@ interface Matrix<E> {\n  * height = высота, width = ширина, e = чем заполнить элементы.\n  * Бросить исключение IllegalArgumentException, если height или width <= 0.\n  */\n-fun <E> createMatrix(height: Int, width: Int, e: E): Matrix<E> = TODO()\n+fun <E> createMatrix(height: Int, width: Int, e: E): Matrix<E> {\n+    if (height <= 0 || width <= 0) throw IllegalArgumentException()\n+    val result = MatrixImpl<E>(height, width)\n+    for (i in 0..height - 1) {\n+        for (j in 0..width - 1)\n+            result[i, j] = e\n+    }\n+    return result\n+}\n \n /**\n  * Средняя сложность\n  *\n  * Реализация интерфейса \"матрица\"\n  */\n-class MatrixImpl<E> : Matrix<E> {\n-    override val height: Int = TODO()\n-\n-    override val width: Int = TODO()\n+class MatrixImpl<E>(override val height: Int, override val width: Int) : Matrix<E> {\n+    private val map = mutableMapOf<Cell, E>()\n \n-    override fun get(row: Int, column: Int): E  = TODO()\n+    override fun get(row: Int, column: Int): E {\n+        val result = map[Cell(row, column)]\n+        when (result) {\n+            null -> throw IllegalArgumentException()\n+            else -> return result\n+        }\n+    }\n \n-    override fun get(cell: Cell): E  = TODO()\n+    override fun get(cell: Cell): E = get(cell.row, cell.column)\n \n     override fun set(row: Int, column: Int, value: E) {\n-        TODO()\n+        map[Cell(row, column)] = value\n     }\n \n     override fun set(cell: Cell, value: E) {\n-        TODO()\n+        map[cell] = value\n     }\n \n-    override fun equals(other: Any?) = TODO()\n+    override fun equals(other: Any?) =\n+            other is MatrixImpl<*> &&\n+                    height == other.height &&\n+                    width == other.width &&\n+                    map == other.map\n \n-    override fun toString(): String = TODO()\n+    override fun toString(): String {\n+        val sb = StringBuilder()\n+        sb.append(\"[\")\n+        for (row in 0..height - 1) {\n+            sb.append(\"[\")\n+            for (column in 0..width - 1) {\n+                sb.append(this[row, column])\n+                if (column != width - 1) sb.append(\",\")","path":"src/lesson7/task1/Matrix.kt","position":86,"original_position":86,"commit_id":"9a02eadf83b7d466f470844fbc4f7d215821c74f","original_commit_id":"9a02eadf83b7d466f470844fbc4f7d215821c74f","user":{"login":"ice-phoenix","id":1929610,"avatar_url":"https://avatars.githubusercontent.com/u/1929610?v=3","gravatar_id":"","url":"https://api.github.com/users/ice-phoenix","html_url":"https://github.com/ice-phoenix","followers_url":"https://api.github.com/users/ice-phoenix/followers","following_url":"https://api.github.com/users/ice-phoenix/following{/other_user}","gists_url":"https://api.github.com/users/ice-phoenix/gists{/gist_id}","starred_url":"https://api.github.com/users/ice-phoenix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ice-phoenix/subscriptions","organizations_url":"https://api.github.com/users/ice-phoenix/orgs","repos_url":"https://api.github.com/users/ice-phoenix/repos","events_url":"https://api.github.com/users/ice-phoenix/events{/privacy}","received_events_url":"https://api.github.com/users/ice-phoenix/received_events","type":"User","site_admin":false},"body":"В таких случаях обычно запятую добавляют всегда, а лишнюю запятую в конце откусывают снаружи цикла","created_at":"2016-11-25T14:17:57Z","updated_at":"2016-11-25T14:18:56Z","html_url":"https://github.com/Kotlin-Polytech/KotlinAsFirst2016/pull/201#discussion_r89623361","pull_request_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/pulls/201","_links":{"self":{"href":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/pulls/comments/89623361"},"html":{"href":"https://github.com/Kotlin-Polytech/KotlinAsFirst2016/pull/201#discussion_r89623361"},"pull_request":{"href":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/pulls/201"}}},"pull_request":{"url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/pulls/201","id":91400291,"html_url":"https://github.com/Kotlin-Polytech/KotlinAsFirst2016/pull/201","diff_url":"https://github.com/Kotlin-Polytech/KotlinAsFirst2016/pull/201.diff","patch_url":"https://github.com/Kotlin-Polytech/KotlinAsFirst2016/pull/201.patch","issue_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/issues/201","number":201,"state":"open","locked":false,"title":"6th lesson","user":{"login":"grafovdenis","id":20505376,"avatar_url":"https://avatars.githubusercontent.com/u/20505376?v=3","gravatar_id":"","url":"https://api.github.com/users/grafovdenis","html_url":"https://github.com/grafovdenis","followers_url":"https://api.github.com/users/grafovdenis/followers","following_url":"https://api.github.com/users/grafovdenis/following{/other_user}","gists_url":"https://api.github.com/users/grafovdenis/gists{/gist_id}","starred_url":"https://api.github.com/users/grafovdenis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grafovdenis/subscriptions","organizations_url":"https://api.github.com/users/grafovdenis/orgs","repos_url":"https://api.github.com/users/grafovdenis/repos","events_url":"https://api.github.com/users/grafovdenis/events{/privacy}","received_events_url":"https://api.github.com/users/grafovdenis/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-28T15:17:48Z","updated_at":"2016-11-25T14:18:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c200fc88753dde468362dc988e468fc419febff1","assignee":{"login":"ice-phoenix","id":1929610,"avatar_url":"https://avatars.githubusercontent.com/u/1929610?v=3","gravatar_id":"","url":"https://api.github.com/users/ice-phoenix","html_url":"https://github.com/ice-phoenix","followers_url":"https://api.github.com/users/ice-phoenix/followers","following_url":"https://api.github.com/users/ice-phoenix/following{/other_user}","gists_url":"https://api.github.com/users/ice-phoenix/gists{/gist_id}","starred_url":"https://api.github.com/users/ice-phoenix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ice-phoenix/subscriptions","organizations_url":"https://api.github.com/users/ice-phoenix/orgs","repos_url":"https://api.github.com/users/ice-phoenix/repos","events_url":"https://api.github.com/users/ice-phoenix/events{/privacy}","received_events_url":"https://api.github.com/users/ice-phoenix/received_events","type":"User","site_admin":false},"assignees":[{"login":"ice-phoenix","id":1929610,"avatar_url":"https://avatars.githubusercontent.com/u/1929610?v=3","gravatar_id":"","url":"https://api.github.com/users/ice-phoenix","html_url":"https://github.com/ice-phoenix","followers_url":"https://api.github.com/users/ice-phoenix/followers","following_url":"https://api.github.com/users/ice-phoenix/following{/other_user}","gists_url":"https://api.github.com/users/ice-phoenix/gists{/gist_id}","starred_url":"https://api.github.com/users/ice-phoenix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ice-phoenix/subscriptions","organizations_url":"https://api.github.com/users/ice-phoenix/orgs","repos_url":"https://api.github.com/users/ice-phoenix/repos","events_url":"https://api.github.com/users/ice-phoenix/events{/privacy}","received_events_url":"https://api.github.com/users/ice-phoenix/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/pulls/201/commits","review_comments_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/pulls/201/comments","review_comment_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/issues/201/comments","statuses_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/statuses/9a02eadf83b7d466f470844fbc4f7d215821c74f","head":{"label":"grafovdenis:master","ref":"master","sha":"9a02eadf83b7d466f470844fbc4f7d215821c74f","user":{"login":"grafovdenis","id":20505376,"avatar_url":"https://avatars.githubusercontent.com/u/20505376?v=3","gravatar_id":"","url":"https://api.github.com/users/grafovdenis","html_url":"https://github.com/grafovdenis","followers_url":"https://api.github.com/users/grafovdenis/followers","following_url":"https://api.github.com/users/grafovdenis/following{/other_user}","gists_url":"https://api.github.com/users/grafovdenis/gists{/gist_id}","starred_url":"https://api.github.com/users/grafovdenis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grafovdenis/subscriptions","organizations_url":"https://api.github.com/users/grafovdenis/orgs","repos_url":"https://api.github.com/users/grafovdenis/repos","events_url":"https://api.github.com/users/grafovdenis/events{/privacy}","received_events_url":"https://api.github.com/users/grafovdenis/received_events","type":"User","site_admin":false},"repo":{"id":67518245,"name":"KotlinAsFirst2016","full_name":"grafovdenis/KotlinAsFirst2016","owner":{"login":"grafovdenis","id":20505376,"avatar_url":"https://avatars.githubusercontent.com/u/20505376?v=3","gravatar_id":"","url":"https://api.github.com/users/grafovdenis","html_url":"https://github.com/grafovdenis","followers_url":"https://api.github.com/users/grafovdenis/followers","following_url":"https://api.github.com/users/grafovdenis/following{/other_user}","gists_url":"https://api.github.com/users/grafovdenis/gists{/gist_id}","starred_url":"https://api.github.com/users/grafovdenis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grafovdenis/subscriptions","organizations_url":"https://api.github.com/users/grafovdenis/orgs","repos_url":"https://api.github.com/users/grafovdenis/repos","events_url":"https://api.github.com/users/grafovdenis/events{/privacy}","received_events_url":"https://api.github.com/users/grafovdenis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/grafovdenis/KotlinAsFirst2016","description":null,"fork":true,"url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016","forks_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/forks","keys_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/keys{/key_id}","collaborators_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/teams","hooks_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/hooks","issue_events_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/issues/events{/number}","events_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/events","assignees_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/assignees{/user}","branches_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/branches{/branch}","tags_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/tags","blobs_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/git/refs{/sha}","trees_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/git/trees{/sha}","statuses_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/statuses/{sha}","languages_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/languages","stargazers_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/stargazers","contributors_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/contributors","subscribers_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/subscribers","subscription_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/subscription","commits_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/commits{/sha}","git_commits_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/git/commits{/sha}","comments_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/comments{/number}","issue_comment_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/issues/comments{/number}","contents_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/contents/{+path}","compare_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/compare/{base}...{head}","merges_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/merges","archive_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/downloads","issues_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/issues{/number}","pulls_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/pulls{/number}","milestones_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/milestones{/number}","notifications_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/labels{/name}","releases_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/releases{/id}","deployments_url":"https://api.github.com/repos/grafovdenis/KotlinAsFirst2016/deployments","created_at":"2016-09-06T14:57:41Z","updated_at":"2016-09-06T14:57:42Z","pushed_at":"2016-11-24T21:14:11Z","git_url":"git://github.com/grafovdenis/KotlinAsFirst2016.git","ssh_url":"git@github.com:grafovdenis/KotlinAsFirst2016.git","clone_url":"https://github.com/grafovdenis/KotlinAsFirst2016.git","svn_url":"https://github.com/grafovdenis/KotlinAsFirst2016","homepage":null,"size":455,"stargazers_count":0,"watchers_count":0,"language":"Kotlin","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":"Kotlin-Polytech:master","ref":"master","sha":"8c89ffac9a855183dc947ddc816cee1b59db666f","user":{"login":"Kotlin-Polytech","id":20967488,"avatar_url":"https://avatars.githubusercontent.com/u/20967488?v=3","gravatar_id":"","url":"https://api.github.com/users/Kotlin-Polytech","html_url":"https://github.com/Kotlin-Polytech","followers_url":"https://api.github.com/users/Kotlin-Polytech/followers","following_url":"https://api.github.com/users/Kotlin-Polytech/following{/other_user}","gists_url":"https://api.github.com/users/Kotlin-Polytech/gists{/gist_id}","starred_url":"https://api.github.com/users/Kotlin-Polytech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kotlin-Polytech/subscriptions","organizations_url":"https://api.github.com/users/Kotlin-Polytech/orgs","repos_url":"https://api.github.com/users/Kotlin-Polytech/repos","events_url":"https://api.github.com/users/Kotlin-Polytech/events{/privacy}","received_events_url":"https://api.github.com/users/Kotlin-Polytech/received_events","type":"Organization","site_admin":false},"repo":{"id":67405509,"name":"KotlinAsFirst2016","full_name":"Kotlin-Polytech/KotlinAsFirst2016","owner":{"login":"Kotlin-Polytech","id":20967488,"avatar_url":"https://avatars.githubusercontent.com/u/20967488?v=3","gravatar_id":"","url":"https://api.github.com/users/Kotlin-Polytech","html_url":"https://github.com/Kotlin-Polytech","followers_url":"https://api.github.com/users/Kotlin-Polytech/followers","following_url":"https://api.github.com/users/Kotlin-Polytech/following{/other_user}","gists_url":"https://api.github.com/users/Kotlin-Polytech/gists{/gist_id}","starred_url":"https://api.github.com/users/Kotlin-Polytech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kotlin-Polytech/subscriptions","organizations_url":"https://api.github.com/users/Kotlin-Polytech/orgs","repos_url":"https://api.github.com/users/Kotlin-Polytech/repos","events_url":"https://api.github.com/users/Kotlin-Polytech/events{/privacy}","received_events_url":"https://api.github.com/users/Kotlin-Polytech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Kotlin-Polytech/KotlinAsFirst2016","description":null,"fork":false,"url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016","forks_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/forks","keys_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/teams","hooks_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/hooks","issue_events_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/issues/events{/number}","events_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/events","assignees_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/assignees{/user}","branches_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/branches{/branch}","tags_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/tags","blobs_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/git/refs{/sha}","trees_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/statuses/{sha}","languages_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/languages","stargazers_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/stargazers","contributors_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/contributors","subscribers_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/subscribers","subscription_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/subscription","commits_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/commits{/sha}","git_commits_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/git/commits{/sha}","comments_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/comments{/number}","issue_comment_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/issues/comments{/number}","contents_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/contents/{+path}","compare_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/merges","archive_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/downloads","issues_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/issues{/number}","pulls_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/pulls{/number}","milestones_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/milestones{/number}","notifications_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/labels{/name}","releases_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/releases{/id}","deployments_url":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/deployments","created_at":"2016-09-05T09:06:26Z","updated_at":"2016-11-23T10:17:58Z","pushed_at":"2016-11-25T14:09:21Z","git_url":"git://github.com/Kotlin-Polytech/KotlinAsFirst2016.git","ssh_url":"git@github.com:Kotlin-Polytech/KotlinAsFirst2016.git","clone_url":"https://github.com/Kotlin-Polytech/KotlinAsFirst2016.git","svn_url":"https://github.com/Kotlin-Polytech/KotlinAsFirst2016","homepage":null,"size":23869,"stargazers_count":18,"watchers_count":18,"language":"Kotlin","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":101,"mirror_url":null,"open_issues_count":83,"forks":101,"open_issues":83,"watchers":18,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/pulls/201"},"html":{"href":"https://github.com/Kotlin-Polytech/KotlinAsFirst2016/pull/201"},"issue":{"href":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/issues/201"},"comments":{"href":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/issues/201/comments"},"review_comments":{"href":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/pulls/201/comments"},"review_comment":{"href":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/pulls/201/commits"},"statuses":{"href":"https://api.github.com/repos/Kotlin-Polytech/KotlinAsFirst2016/statuses/9a02eadf83b7d466f470844fbc4f7d215821c74f"}}}}
{"actor":{"display_login":"ice-phoenix"}}