{"action":"created","comment":{"url":"https://api.github.com/repos/java-course-au/assignments/pulls/comments/46091436","id":46091436,"diff_hunk":"@@ -1,25 +1,85 @@\n package ru.spbau.mit;\n \n+import java.lang.reflect.Constructor;\n+import java.lang.reflect.InvocationTargetException;\n import java.util.*;\n+import java.util.concurrent.RunnableFuture;\n \n \n public class GameServerImpl implements GameServer {\n-    public GameServerImpl(String gameClassName, Properties properties) {\n-        throw new UnsupportedOperationException(\"TODO: implement\");\n+    private int connectionNumber = 0;\n+    private Game game;\n+    private HashMap <String, Connection> connections = new HashMap<String, Connection>();\n+\n+    public GameServerImpl(String gameClassName, Properties properties) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {\n+        Class <?> gameClass = Class.forName(gameClassName);\n+        game = (Game) gameClass.getConstructor(GameServer.class).newInstance(this);\n+        for (String property : properties.stringPropertyNames()) {\n+            String methodName = \"set\" + property.substring(0, 1).toUpperCase() + property.substring(1);\n+            try {\n+                int number = Integer.parseInt(properties.getProperty(property));\n+                try {\n+                    gameClass.getMethod(methodName, int.class).invoke(game, number);\n+                } catch (Exception exception) {\n+                    exception.printStackTrace();\n+                }","path":"src/main/java/ru/spbau/mit/GameServerImpl.java","position":27,"original_position":27,"commit_id":"908a066e2b471030987c1b767e1f683a1e118875","original_commit_id":"908a066e2b471030987c1b767e1f683a1e118875","user":{"login":"dzharkov","id":863207,"avatar_url":"https://avatars.githubusercontent.com/u/863207?v=3","gravatar_id":"","url":"https://api.github.com/users/dzharkov","html_url":"https://github.com/dzharkov","followers_url":"https://api.github.com/users/dzharkov/followers","following_url":"https://api.github.com/users/dzharkov/following{/other_user}","gists_url":"https://api.github.com/users/dzharkov/gists{/gist_id}","starred_url":"https://api.github.com/users/dzharkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzharkov/subscriptions","organizations_url":"https://api.github.com/users/dzharkov/orgs","repos_url":"https://api.github.com/users/dzharkov/repos","events_url":"https://api.github.com/users/dzharkov/events{/privacy}","received_events_url":"https://api.github.com/users/dzharkov/received_events","type":"User","site_admin":false},"body":"1. Ужасная вложенность из try/catch\r\n2. Копипаст всего подряд\r\n3. И все это на пустом месте\r\n\r\nПредлагаю в качестве упражнения переписать все так, чтобы:\r\n1. Для парсинга инта по-прежнему использовался parseInt\r\n2. В конструкторе не было логики по ловле NumberFormatException\r\n3. Не было дублирование подвыражений `getMethod`/`invoke`/`properties.getProperty(property)`","created_at":"2015-11-29T12:28:35Z","updated_at":"2015-11-29T12:28:35Z","html_url":"https://github.com/java-course-au/assignments/pull/82#discussion_r46091436","pull_request_url":"https://api.github.com/repos/java-course-au/assignments/pulls/82","_links":{"self":{"href":"https://api.github.com/repos/java-course-au/assignments/pulls/comments/46091436"},"html":{"href":"https://github.com/java-course-au/assignments/pull/82#discussion_r46091436"},"pull_request":{"href":"https://api.github.com/repos/java-course-au/assignments/pulls/82"}}},"pull_request":{"url":"https://api.github.com/repos/java-course-au/assignments/pulls/82","id":51004444,"html_url":"https://github.com/java-course-au/assignments/pull/82","diff_url":"https://github.com/java-course-au/assignments/pull/82.diff","patch_url":"https://github.com/java-course-au/assignments/pull/82.patch","issue_url":"https://api.github.com/repos/java-course-au/assignments/issues/82","number":82,"state":"open","locked":false,"title":"ДЗ 03, Подгузов Никита, подгруппа 1","user":{"login":"Nikitosh","id":11414730,"avatar_url":"https://avatars.githubusercontent.com/u/11414730?v=3","gravatar_id":"","url":"https://api.github.com/users/Nikitosh","html_url":"https://github.com/Nikitosh","followers_url":"https://api.github.com/users/Nikitosh/followers","following_url":"https://api.github.com/users/Nikitosh/following{/other_user}","gists_url":"https://api.github.com/users/Nikitosh/gists{/gist_id}","starred_url":"https://api.github.com/users/Nikitosh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nikitosh/subscriptions","organizations_url":"https://api.github.com/users/Nikitosh/orgs","repos_url":"https://api.github.com/users/Nikitosh/repos","events_url":"https://api.github.com/users/Nikitosh/events{/privacy}","received_events_url":"https://api.github.com/users/Nikitosh/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-11-17T21:06:14Z","updated_at":"2015-11-29T12:28:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5d5319ded27a7c8ae1b2a5a6c7ecbf4583bb2138","assignee":{"login":"dzharkov","id":863207,"avatar_url":"https://avatars.githubusercontent.com/u/863207?v=3","gravatar_id":"","url":"https://api.github.com/users/dzharkov","html_url":"https://github.com/dzharkov","followers_url":"https://api.github.com/users/dzharkov/followers","following_url":"https://api.github.com/users/dzharkov/following{/other_user}","gists_url":"https://api.github.com/users/dzharkov/gists{/gist_id}","starred_url":"https://api.github.com/users/dzharkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzharkov/subscriptions","organizations_url":"https://api.github.com/users/dzharkov/orgs","repos_url":"https://api.github.com/users/dzharkov/repos","events_url":"https://api.github.com/users/dzharkov/events{/privacy}","received_events_url":"https://api.github.com/users/dzharkov/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/java-course-au/assignments/pulls/82/commits","review_comments_url":"https://api.github.com/repos/java-course-au/assignments/pulls/82/comments","review_comment_url":"https://api.github.com/repos/java-course-au/assignments/pulls/comments{/number}","comments_url":"https://api.github.com/repos/java-course-au/assignments/issues/82/comments","statuses_url":"https://api.github.com/repos/java-course-au/assignments/statuses/908a066e2b471030987c1b767e1f683a1e118875","head":{"label":"Nikitosh:03-game-server","ref":"03-game-server","sha":"908a066e2b471030987c1b767e1f683a1e118875","user":{"login":"Nikitosh","id":11414730,"avatar_url":"https://avatars.githubusercontent.com/u/11414730?v=3","gravatar_id":"","url":"https://api.github.com/users/Nikitosh","html_url":"https://github.com/Nikitosh","followers_url":"https://api.github.com/users/Nikitosh/followers","following_url":"https://api.github.com/users/Nikitosh/following{/other_user}","gists_url":"https://api.github.com/users/Nikitosh/gists{/gist_id}","starred_url":"https://api.github.com/users/Nikitosh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nikitosh/subscriptions","organizations_url":"https://api.github.com/users/Nikitosh/orgs","repos_url":"https://api.github.com/users/Nikitosh/repos","events_url":"https://api.github.com/users/Nikitosh/events{/privacy}","received_events_url":"https://api.github.com/users/Nikitosh/received_events","type":"User","site_admin":false},"repo":{"id":42788868,"name":"assignments","full_name":"Nikitosh/assignments","owner":{"login":"Nikitosh","id":11414730,"avatar_url":"https://avatars.githubusercontent.com/u/11414730?v=3","gravatar_id":"","url":"https://api.github.com/users/Nikitosh","html_url":"https://github.com/Nikitosh","followers_url":"https://api.github.com/users/Nikitosh/followers","following_url":"https://api.github.com/users/Nikitosh/following{/other_user}","gists_url":"https://api.github.com/users/Nikitosh/gists{/gist_id}","starred_url":"https://api.github.com/users/Nikitosh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nikitosh/subscriptions","organizations_url":"https://api.github.com/users/Nikitosh/orgs","repos_url":"https://api.github.com/users/Nikitosh/repos","events_url":"https://api.github.com/users/Nikitosh/events{/privacy}","received_events_url":"https://api.github.com/users/Nikitosh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Nikitosh/assignments","description":"Домашние задания по Java","fork":true,"url":"https://api.github.com/repos/Nikitosh/assignments","forks_url":"https://api.github.com/repos/Nikitosh/assignments/forks","keys_url":"https://api.github.com/repos/Nikitosh/assignments/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Nikitosh/assignments/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Nikitosh/assignments/teams","hooks_url":"https://api.github.com/repos/Nikitosh/assignments/hooks","issue_events_url":"https://api.github.com/repos/Nikitosh/assignments/issues/events{/number}","events_url":"https://api.github.com/repos/Nikitosh/assignments/events","assignees_url":"https://api.github.com/repos/Nikitosh/assignments/assignees{/user}","branches_url":"https://api.github.com/repos/Nikitosh/assignments/branches{/branch}","tags_url":"https://api.github.com/repos/Nikitosh/assignments/tags","blobs_url":"https://api.github.com/repos/Nikitosh/assignments/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Nikitosh/assignments/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Nikitosh/assignments/git/refs{/sha}","trees_url":"https://api.github.com/repos/Nikitosh/assignments/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Nikitosh/assignments/statuses/{sha}","languages_url":"https://api.github.com/repos/Nikitosh/assignments/languages","stargazers_url":"https://api.github.com/repos/Nikitosh/assignments/stargazers","contributors_url":"https://api.github.com/repos/Nikitosh/assignments/contributors","subscribers_url":"https://api.github.com/repos/Nikitosh/assignments/subscribers","subscription_url":"https://api.github.com/repos/Nikitosh/assignments/subscription","commits_url":"https://api.github.com/repos/Nikitosh/assignments/commits{/sha}","git_commits_url":"https://api.github.com/repos/Nikitosh/assignments/git/commits{/sha}","comments_url":"https://api.github.com/repos/Nikitosh/assignments/comments{/number}","issue_comment_url":"https://api.github.com/repos/Nikitosh/assignments/issues/comments{/number}","contents_url":"https://api.github.com/repos/Nikitosh/assignments/contents/{+path}","compare_url":"https://api.github.com/repos/Nikitosh/assignments/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Nikitosh/assignments/merges","archive_url":"https://api.github.com/repos/Nikitosh/assignments/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Nikitosh/assignments/downloads","issues_url":"https://api.github.com/repos/Nikitosh/assignments/issues{/number}","pulls_url":"https://api.github.com/repos/Nikitosh/assignments/pulls{/number}","milestones_url":"https://api.github.com/repos/Nikitosh/assignments/milestones{/number}","notifications_url":"https://api.github.com/repos/Nikitosh/assignments/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Nikitosh/assignments/labels{/name}","releases_url":"https://api.github.com/repos/Nikitosh/assignments/releases{/id}","created_at":"2015-09-19T20:39:11Z","updated_at":"2015-09-15T08:01:56Z","pushed_at":"2015-11-29T11:14:35Z","git_url":"git://github.com/Nikitosh/assignments.git","ssh_url":"git@github.com:Nikitosh/assignments.git","clone_url":"https://github.com/Nikitosh/assignments.git","svn_url":"https://github.com/Nikitosh/assignments","homepage":"http://mit.spbau.ru/sewiki/index.php/Java_2_2015","size":61,"stargazers_count":0,"watchers_count":0,"language":null,"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":"java-course-au:03-game-server","ref":"03-game-server","sha":"5be475c33d4d96a9be848ddd569ce7909025ae4c","user":{"login":"java-course-au","id":14248092,"avatar_url":"https://avatars.githubusercontent.com/u/14248092?v=3","gravatar_id":"","url":"https://api.github.com/users/java-course-au","html_url":"https://github.com/java-course-au","followers_url":"https://api.github.com/users/java-course-au/followers","following_url":"https://api.github.com/users/java-course-au/following{/other_user}","gists_url":"https://api.github.com/users/java-course-au/gists{/gist_id}","starred_url":"https://api.github.com/users/java-course-au/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/java-course-au/subscriptions","organizations_url":"https://api.github.com/users/java-course-au/orgs","repos_url":"https://api.github.com/users/java-course-au/repos","events_url":"https://api.github.com/users/java-course-au/events{/privacy}","received_events_url":"https://api.github.com/users/java-course-au/received_events","type":"Organization","site_admin":false},"repo":{"id":42502722,"name":"assignments","full_name":"java-course-au/assignments","owner":{"login":"java-course-au","id":14248092,"avatar_url":"https://avatars.githubusercontent.com/u/14248092?v=3","gravatar_id":"","url":"https://api.github.com/users/java-course-au","html_url":"https://github.com/java-course-au","followers_url":"https://api.github.com/users/java-course-au/followers","following_url":"https://api.github.com/users/java-course-au/following{/other_user}","gists_url":"https://api.github.com/users/java-course-au/gists{/gist_id}","starred_url":"https://api.github.com/users/java-course-au/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/java-course-au/subscriptions","organizations_url":"https://api.github.com/users/java-course-au/orgs","repos_url":"https://api.github.com/users/java-course-au/repos","events_url":"https://api.github.com/users/java-course-au/events{/privacy}","received_events_url":"https://api.github.com/users/java-course-au/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/java-course-au/assignments","description":"Домашние задания по Java","fork":false,"url":"https://api.github.com/repos/java-course-au/assignments","forks_url":"https://api.github.com/repos/java-course-au/assignments/forks","keys_url":"https://api.github.com/repos/java-course-au/assignments/keys{/key_id}","collaborators_url":"https://api.github.com/repos/java-course-au/assignments/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/java-course-au/assignments/teams","hooks_url":"https://api.github.com/repos/java-course-au/assignments/hooks","issue_events_url":"https://api.github.com/repos/java-course-au/assignments/issues/events{/number}","events_url":"https://api.github.com/repos/java-course-au/assignments/events","assignees_url":"https://api.github.com/repos/java-course-au/assignments/assignees{/user}","branches_url":"https://api.github.com/repos/java-course-au/assignments/branches{/branch}","tags_url":"https://api.github.com/repos/java-course-au/assignments/tags","blobs_url":"https://api.github.com/repos/java-course-au/assignments/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/java-course-au/assignments/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/java-course-au/assignments/git/refs{/sha}","trees_url":"https://api.github.com/repos/java-course-au/assignments/git/trees{/sha}","statuses_url":"https://api.github.com/repos/java-course-au/assignments/statuses/{sha}","languages_url":"https://api.github.com/repos/java-course-au/assignments/languages","stargazers_url":"https://api.github.com/repos/java-course-au/assignments/stargazers","contributors_url":"https://api.github.com/repos/java-course-au/assignments/contributors","subscribers_url":"https://api.github.com/repos/java-course-au/assignments/subscribers","subscription_url":"https://api.github.com/repos/java-course-au/assignments/subscription","commits_url":"https://api.github.com/repos/java-course-au/assignments/commits{/sha}","git_commits_url":"https://api.github.com/repos/java-course-au/assignments/git/commits{/sha}","comments_url":"https://api.github.com/repos/java-course-au/assignments/comments{/number}","issue_comment_url":"https://api.github.com/repos/java-course-au/assignments/issues/comments{/number}","contents_url":"https://api.github.com/repos/java-course-au/assignments/contents/{+path}","compare_url":"https://api.github.com/repos/java-course-au/assignments/compare/{base}...{head}","merges_url":"https://api.github.com/repos/java-course-au/assignments/merges","archive_url":"https://api.github.com/repos/java-course-au/assignments/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/java-course-au/assignments/downloads","issues_url":"https://api.github.com/repos/java-course-au/assignments/issues{/number}","pulls_url":"https://api.github.com/repos/java-course-au/assignments/pulls{/number}","milestones_url":"https://api.github.com/repos/java-course-au/assignments/milestones{/number}","notifications_url":"https://api.github.com/repos/java-course-au/assignments/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/java-course-au/assignments/labels{/name}","releases_url":"https://api.github.com/repos/java-course-au/assignments/releases{/id}","created_at":"2015-09-15T07:36:54Z","updated_at":"2015-10-04T08:47:09Z","pushed_at":"2015-11-29T11:14:35Z","git_url":"git://github.com/java-course-au/assignments.git","ssh_url":"git@github.com:java-course-au/assignments.git","clone_url":"https://github.com/java-course-au/assignments.git","svn_url":"https://github.com/java-course-au/assignments","homepage":"http://mit.spbau.ru/sewiki/index.php/Java_2_2015","size":543,"stargazers_count":2,"watchers_count":2,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":17,"forks":26,"open_issues":17,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/java-course-au/assignments/pulls/82"},"html":{"href":"https://github.com/java-course-au/assignments/pull/82"},"issue":{"href":"https://api.github.com/repos/java-course-au/assignments/issues/82"},"comments":{"href":"https://api.github.com/repos/java-course-au/assignments/issues/82/comments"},"review_comments":{"href":"https://api.github.com/repos/java-course-au/assignments/pulls/82/comments"},"review_comment":{"href":"https://api.github.com/repos/java-course-au/assignments/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/java-course-au/assignments/pulls/82/commits"},"statuses":{"href":"https://api.github.com/repos/java-course-au/assignments/statuses/908a066e2b471030987c1b767e1f683a1e118875"}}}}