{"id":10512,"date":"2020-10-17T22:03:01","date_gmt":"2020-10-17T13:03:01","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=10512"},"modified":"2020-10-25T09:19:47","modified_gmt":"2020-10-25T00:19:47","slug":"state-%ed%8c%a8%ed%84%b4","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=10512","title":{"rendered":"[GoF] State \ud328\ud134"},"content":{"rendered":"<h4>\ud328\ud134\uba85\uce6d<\/h4>\n<p>State<\/p>\n<h4>\ud544\uc694\ud55c \uc0c1\ud669<\/h4>\n<p>\uc0c1\ud0dc\uc5d0 \ub530\ub77c \uc2e4\ud589\ub418\ub294 \uae30\ub2a5\uc774 \ub2ec\ub77c\uc9c8\ub54c \uc720\uc5f0\ud558\uac8c \ub300\uc751\ud560 \uc218 \uc788\ub294 \ud328\ud134\uc774\ub2e4.<\/p>\n<h4>\uc608\uc81c \ucf54\ub4dc<\/h4>\n<p><img decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2020\/10\/state.png\" alt=\"\" width=\"800\" class=\"aligncenter size-full wp-image-10513\" \/><\/p>\n<p>7\uc77c\uac04 \ud558\ub8e8 \ud558\ub8e8\uc5d0 \ub300\ud55c \uc77c\uc815\uc744 \uc8fc\uc0ac\uc704\ub97c \ub358\uc838 \uc9dd\uc218\ub0a0\uc5d0\ub294 \ub180\uace0 \ud640\uc218\ub0a0\uc5d0\ub294 \uacf5\ubd80\ub97c \ud558\ub294 \uc2dc\uc2a4\ud15c\uc774\ub2e4. \uc5ec\uae30\uc11c \uc0c1\ud0dc\ub294 \uc8fc\uc0ac\uc704\uac00 \uc9dd\uc218\uc778\uc9c0 \ud640\uc218\uc778\uc9c0\uc774\ub2e4. \ub2e4\uc591\ud55c \uc0c1\ud0dc\ub97c \ub3d9\uc77c\ud55c \uc778\ud130\ud398\uc774\uc2a4\ub85c \ub2e4\ub8f0 \uc218 \uc788\ub3c4\ub85d State \uc778\ud130\ud398\uc774\uc2a4\ub97c \ub450\uace0 \uc774 State\ub97c PlayState\uc640 StudyState\uac00 \uad6c\ud604\ud55c\ub2e4. \uac01\uac01\uc740 \uc0c1\ud0dc\uc5d0 \ub530\ub978 \ub180\uae30\uc640 \uacf5\ubd80\ud558\uae30\uc774\ub2e4. Schedule\ub294 \uc0c1\ud0dc\ub97c \ubcc0\uacbd\ud558\ub294 \ud074\ub798\uc2a4\uc774\ub2e4. \uba3c\uc800 State \uc778\ud130\ud398\uc774\uc2a4\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">\r\npackage tstThread;\r\n\r\npublic interface State {\r\n\tvoid morning();\r\n\tvoid afternoon();\r\n\tvoid night();\r\n}\r\n<\/pre>\n<p>\ub2e4\uc74c\uc740 \uacf5\ubd80\ud558\uae30 \uc0c1\ud0dc\uc5d0 \ub300\ud55c StudyState \ud074\ub798\uc2a4\uc774\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">\r\npackage tstThread;\r\n\r\npublic class StudyState implements State {\r\n\t@Override\r\n\tpublic void morning() {\r\n\t\tSystem.out.println(\"I'm studying the math.\");\r\n\t}\r\n\r\n\t@Override\r\n\tpublic void afternoon() {\r\n\t\tSystem.out.println(\"I'm studying the programming.\");\r\n\t}\r\n\r\n\t@Override\r\n\tpublic void night() {\r\n\t\tSystem.out.println(\"I'm studying the physics.\");\r\n\t}\r\n}\r\n<\/pre>\n<p>\ub2e4\uc74c\uc740 \ub180\uae30 \uc0c1\ud0dc\uc5d0 \ub300\ud55c PlayState \ud074\ub798\uc2a4\uc774\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">\r\npackage tstThread;\r\n\r\npublic class PlayState implements State {\r\n\r\n\t@Override\r\n\tpublic void morning() {\r\n\t\tSystem.out.println(\"I am playing the piano.\");\r\n\t}\r\n\r\n\t@Override\r\n\tpublic void afternoon() {\r\n\t\tSystem.out.println(\"I am playing the starcraft game.\");\r\n\t}\r\n\r\n\t@Override\r\n\tpublic void night() {\r\n\t\tSystem.out.println(\"I am listening the pop song.\");\r\n\t}\r\n}\r\n<\/pre>\n<p>\ub2e4\uc74c\uc740 \uc77c\uc8fc\uc77c\uc5d0 \ub300\ud55c \uc2dc\uac04 \ud750\ub984\uc744 \uc81c\uc5b4\ud558\uace0 \uc8fc\uc0ac\uc704\ub97c \ub358\uc800 \uc0c1\ud0dc\ub97c \ubcc0\uacbd\ud558\ub294 Schedule \ud074\ub798\uc2a4\uc774\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">\r\npackage tstThread;\r\n\r\npublic class Schedule {\r\n\tprivate State state;\r\n\t\r\n\tpublic void setState(State state) {\r\n\t\tthis.state = state;\r\n\t}\r\n\t\r\n\tpublic void doInTheMorning() {\r\n\t\tif(state != null) {\r\n\t\t\tSystem.out.print(\"[Morning] \");\r\n\t\t\tstate.morning();\r\n\t\t}\r\n\t}\r\n\t\r\n\tpublic void doInTheAfternoon() {\r\n\t\tif(state != null) {\r\n\t\t\tSystem.out.print(\"[Afternoon] \");\r\n\t\t\tstate.afternoon();\r\n\t\t}\r\n\t}\r\n\t\r\n\tpublic void doInTheNight() {\r\n\t\tif(state != null) {\r\n\t\t\tSystem.out.print(\"[Night] \");\r\n\t\t\tstate.night();\r\n\t\t}\r\n\t}\r\n}\r\n<\/pre>\n<p>\uc9c0\uae08\uae4c\uc9c0\uc758 \ud074\ub798\uc2a4\ub97c \uc2e4\ud589\ud558\ub294 \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">\r\npackage tstThread;\r\n\r\nimport java.util.Random;\r\n\r\npublic class Main {\r\n\tprivate static Random dice = new Random();\r\n\tpublic static void main(String[] args) {\r\n\t\tSchedule schedule = new Schedule();\r\n\t\t\r\n\t\tString days[] = { \"Sunday\", \"Monday\", \"Tuesday\", \"Thursday\", \"Friday\", \"Saturday\" };\r\n\t\tfor(int nDay=0; nDay<6; nDay++) {\r\n\t\t\tint nDice = dice.nextInt(7);\r\n\t\t\t\r\n\t\t\tif(nDice % 2 == 0) {\r\n\t\t\t\tschedule.setState(new PlayState());\r\n\t\t\t} else {\r\n\t\t\t\tschedule.setState(new StudyState());\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tSystem.out.println();\r\n\t\t\tSystem.out.println(\"# \" + days[nDay]);\r\n\t\t\tschedule.doInTheMorning();\r\n\t\t\tschedule.doInTheAfternoon();\r\n\t\t\tschedule.doInTheNight();\r\n\t\t}\r\n\t}\r\n}\r\n<\/pre>\n<p>\uc2e4\ud589\uacb0\uacfc\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre class='code'>\r\n# Sunday\r\n[Morning] I am playing the piano.\r\n[Afternoon] I am playing the starcraft game.\r\n[Night] I am listening the pop song.\r\n\r\n# Monday\r\n[Morning] I am playing the piano.\r\n[Afternoon] I am playing the starcraft game.\r\n[Night] I am listening the pop song.\r\n\r\n# Tuesday\r\n[Morning] I am playing the piano.\r\n[Afternoon] I am playing the starcraft game.\r\n[Night] I am listening the pop song.\r\n\r\n# Thursday\r\n[Morning] I am playing the piano.\r\n[Afternoon] I am playing the starcraft game.\r\n[Night] I am listening the pop song.\r\n\r\n# Friday\r\n[Morning] I'm studying the math.\r\n[Afternoon] I'm studying the programming.\r\n[Night] I'm studying the physics.\r\n\r\n# Saturday\r\n[Morning] I'm studying the math.\r\n[Afternoon] I'm studying the programming.\r\n[Night] I'm studying the physics.\r\n<\/pre>\n<div style='background:#efefef;border-radius:8px;padding:12px 24px'>\uc774 \uae00\uc740 \uc18c\ud504\ud2b8\uc6e8\uc5b4 \uc124\uacc4\uc758 \uae30\ubc18\uc774 \ub418\ub294 GoF\uc758 \ub514\uc790\uc778\ud328\ud134\uc5d0 \ub300\ud55c \uac15\uc758\uc790\ub8cc\uc785\ub2c8\ub2e4. \uc644\uc804\ud55c \uc2e4\uc2b5\uc744 \uc704\ud574 \uc774 \uae00\uc5d0\uc11c \uc18c\uac1c\ud558\ub294 \ud074\ub798\uc2a4 \ub2e4\uc774\uc5b4\uadf8\ub7a8\uacfc \uc608\uc81c \ucf54\ub4dc\ub294 \uc644\uc804\ud558\uac8c \uc2e4\ud589\ub418\ub3c4\ub85d \uc81c\uacf5\ub418\uc9c0\ub9cc, \uc0c1\ub300\uc801\uc73c\ub85c \uc608\uc81c \ucf54\ub4dc\uc640 \uad00\ub828\ub41c \uc124\uba85\uc774 \ud568\ucd95\uc801\uc73c\ub85c \uc81c\uacf5\ub418\uace0 \uc788\uc2b5\ub2c8\ub2e4. \uc774 \uae00\uc5d0 \ub300\ud574 \uad81\uae08\ud55c \uc810\uc774 \uc788\uc73c\uba74 \ub313\uae00\uc744 \ud1b5\ud574 \ub0a8\uaca8\uc8fc\uc2dc\uae30 \ubc14\ub78d\ub2c8\ub2e4.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\ud328\ud134\uba85\uce6d State \ud544\uc694\ud55c \uc0c1\ud669 \uc0c1\ud0dc\uc5d0 \ub530\ub77c \uc2e4\ud589\ub418\ub294 \uae30\ub2a5\uc774 \ub2ec\ub77c\uc9c8\ub54c \uc720\uc5f0\ud558\uac8c \ub300\uc751\ud560 \uc218 \uc788\ub294 \ud328\ud134\uc774\ub2e4. \uc608\uc81c \ucf54\ub4dc 7\uc77c\uac04 \ud558\ub8e8 \ud558\ub8e8\uc5d0 \ub300\ud55c \uc77c\uc815\uc744 \uc8fc\uc0ac\uc704\ub97c \ub358\uc838 \uc9dd\uc218\ub0a0\uc5d0\ub294 \ub180\uace0 \ud640\uc218\ub0a0\uc5d0\ub294 \uacf5\ubd80\ub97c \ud558\ub294 \uc2dc\uc2a4\ud15c\uc774\ub2e4. \uc5ec\uae30\uc11c \uc0c1\ud0dc\ub294 \uc8fc\uc0ac\uc704\uac00 \uc9dd\uc218\uc778\uc9c0 \ud640\uc218\uc778\uc9c0\uc774\ub2e4. \ub2e4\uc591\ud55c \uc0c1\ud0dc\ub97c \ub3d9\uc77c\ud55c \uc778\ud130\ud398\uc774\uc2a4\ub85c \ub2e4\ub8f0 \uc218 \uc788\ub3c4\ub85d State \uc778\ud130\ud398\uc774\uc2a4\ub97c \ub450\uace0 \uc774 State\ub97c PlayState\uc640 StudyState\uac00 \uad6c\ud604\ud55c\ub2e4. \uac01\uac01\uc740 \uc0c1\ud0dc\uc5d0 \ub530\ub978 \ub180\uae30\uc640 \uacf5\ubd80\ud558\uae30\uc774\ub2e4. Schedule\ub294 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=10512\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;[GoF] State \ud328\ud134&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-10512","post","type-post","status-publish","format-standard","hentry","category-design"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/10512","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10512"}],"version-history":[{"count":3,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/10512\/revisions"}],"predecessor-version":[{"id":10553,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/10512\/revisions\/10553"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10512"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}