{"id":131,"date":"2017-05-25T16:50:36","date_gmt":"2017-05-25T07:50:36","guid":{"rendered":"https:\/\/do-gugan.com\/swift\/?p=131"},"modified":"2017-05-28T01:09:48","modified_gmt":"2017-05-27T16:09:48","slug":"%e3%83%91%e3%83%a9%e3%83%a1%e3%83%bc%e3%82%bf-2-%e9%96%a2%e6%95%b0%e3%82%92%e4%bd%9c%e3%82%8b","status":"publish","type":"post","link":"https:\/\/do-gugan.com\/swift\/?p=131","title":{"rendered":"\u30d1\u30e9\u30e1\u30fc\u30bf 2. \u95a2\u6570\u3092\u4f5c\u308b"},"content":{"rendered":"<p>\u3072\u3068\u3064\u306e\u95a2\u6570\u306b\u5f15\u6570\u30922\u3064\u4ee5\u4e0a\u3082\u305f\u305b\u308b\u3053\u3068\u3082\u51fa\u6765\u307e\u3059\u3002<\/p>\n<pre class=\"lang:swift decode:true \" >\u30b9\u30c6\u30fc\u30ad.\u30aa\u30fc\u30c0\u30fc(\u713c\u304d\u52a0\u6e1b:\u30df\u30c7\u30a3\u30a2\u30e0, \u30bd\u30fc\u30b9:\u30ac\u30fc\u30ea\u30c3\u30af)<\/pre>\n<p>\u3066\u306a\u3082\u3093\u3067\u3059\u3002<br \/>\n\u4eca\u56de\u306fturnLock\u3068\u3044\u3046\u95a2\u6570\u306b\u3001up\u3068numberOfTimes\u3068\u3044\u30462\u3064\u306e\u5909\u6570\u3092\u3076\u3089\u3055\u3052\u307e\u3059\u3002up\u306fBool\u578b\u3068\u3042\u308a\u307e\u3059\u3002Bool\u578b\u306ftrue\u304bfalse\u306e\u3069\u3061\u3089\u304b\u304c\u5165\u308b\u3093\u3067\u3057\u305f\u3002up\u304ctrue\u3060\u3063\u305f\u3089\u79fb\u52d5\u677f\u304c\u4e0a\u304c\u308a\u3001false\u306a\u3089\u4e0b\u304c\u308b\u3088\u3046\u306b\u95a2\u6570\u3092\u4f5c\u308b\u3068\u3044\u3046\u304a\u984c\u3067\u3059\u3002\u307e\u305fnumberOftimes\u306f\u305d\u306e\u4e0a\u3052\u4e0b\u3052\u4f5c\u696d\u3092\u3059\u308b\u56de\u6570\u3067\u3059\uff08Int\u578b\u306a\u306e\u3067\u6570\u5b57\u304c\u5165\u308a\u307e\u3059\uff09\u3002\u4f8b\u3048\u3070\u3001<\/p>\n<pre class=\"lang:swift decode:true \" >turnLock(up:true, numberOfTimes:3)<\/pre>\n<p>\u3068\u3057\u305f\u3089\u3001\u677f\u3092\u4e0a\u3052\u308b\u51e6\u7406\u30923\u56de\u5206\u3059\u308b\u3001\u3068\u3044\u3046\u52d5\u4f5c\u306b\u3059\u308b\u308f\u3051\u3067\u3059\u3002<br \/>\n\uff08up\u3068\u3044\u3046\u5909\u6570\u540d\u306f\u3061\u3087\u3063\u3068\u308f\u304b\u308a\u306b\u304f\u3044\u304b\u3082\u77e5\u308c\u307e\u305b\u3093\u3002\u4eca\u307e\u3067\u306e\u30eb\u30fc\u30eb\u3060\u3068\u3001isUp\uff08up\u304b\u3069\u3046\u304b\uff09\u3068\u3044\u3046\u540d\u524d\u3067\u8003\u3048\u305f\u65b9\u304c\u30d4\u30f3\u3068\u304f\u308b\u3067\u3057\u3087\u3046\u304b\uff1f\uff09<\/p>\n<pre class=\"lang:swift decode:true \" >\r\n\/\/2\u4f53\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u6e96\u5099\r\nlet expert = Expert()\r\nlet character = Character()\r\n\r\n\/\/\u304a\u984c\u306e\u95a2\u6570\r\nfunc turnLock(up: Bool, numberOfTimes: Int) {\r\n    \/\/\u56de\u6570\u306e\u3068\u3053\u308d\u306b\u6570\u5b57\u3067\u306f\u306a\u304fnumverOfTimes\u3092\u6307\u5b9a\u3002\u306a\u3093\u3060\u305d\u308c\uff1f\u3068\u306a\u3063\u305f\u3089\u4e0a\u3092\u307f\u308b\u3068\u3001\u3069\u3046\u3084\u3089\u6bce\u56de\u4f1d\u8a00\u3067\u6307\u793a\u3055\u308c\u308b\u3089\u3057\u3044\u305e\u3001\u3068...\r\n    for i in 1 ... numberOfTimes {\r\n        if up == true { \/\/\u3053\u3053\u306eup\u3082\u4f1d\u8a00\uff08=\u5f15\u6570\uff09\u5f85\u3061\u3002\u4f1d\u8a00\u304ctrue\u306a\u3089\u3059\u3050\u4e0b\u3001false\u306a\u3089else\u4ee5\u4e0b\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002\r\n            expert.turnLockUp()\r\n        } else {\r\n            expert.turnLockDown()\r\n        }\r\n    }\r\n}\r\n\r\n\/\/\u3053\u3053\u304b\u3089\u672c\u7de8\u3002\u304a\u984c\u306e\u95a2\u6570\u3092\u6d3b\u7528\u3057\u3066\u30af\u30ea\u30a2\r\nturnLock(up:true, numberOfTimes:3) \/\/\u4e0a\u30783\u56de\r\nexpert.turnLeft()\r\nexpert.turnLeft()\r\nturnLock(up:true, numberOfTimes:3) \/\/\u4e0a\u30783\u56de\r\n\r\ncharacter.move(distance: 3)\r\ncharacter.collectGem()\r\ncharacter.turnLeft()\r\ncharacter.turnLeft()\r\ncharacter.move(distance: 2)\r\nturnLock(up:false, numberOfTimes:3) \/\/\u4e0b\u30783\u56de\r\ncharacter.turnLeft()\r\ncharacter.move(distance: 1)\r\ncharacter.turnRight()\r\ncharacter.move(distance: 1)\r\ncharacter.collectGem()\r\ncharacter.turnRight()\r\ncharacter.turnRight()\r\ncharacter.move(distance: 1)\r\nturnLock(up:true, numberOfTimes:1) \/\/\u4e0a\u30781\u56de\r\nexpert.turnRight()\r\nexpert.turnRight()\r\nturnLock(up:false, numberOfTimes:2) \/\/\u4e0b\u30782\u56de\r\ncharacter.move(distance: 2)\r\ncharacter.collectGem()<\/pre>\n<p>\u3061\u306a\u307f\u306b\u3001\u81ea\u5206\u3067\u7528\u610f\u3057\u305f\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u6642\u3001\u305d\u306e\u5bfe\u8c61\u3068\u3057\u3066\u3001\u5148\u982d\u306b\u300cexpert.\u300d\u3092\u3064\u3051\u308b\u3079\u304d\u304b\u3069\u3046\u304b\u6c17\u306b\u306a\u3063\u305f\u65b9\u3082\u3044\u308b\u304b\u3082\u77e5\u308c\u307e\u305b\u3093\u3002\u73fe\u72b6\u3067\u306f\u3064\u3051\u3066\u3082\u3064\u3051\u306a\u304f\u3066\u3082\u52d5\u4f5c\u306f\u540c\u3058\u307f\u305f\u3044\u3067\u3059\u3002\u4e00\u65b9\u3001\u95a2\u6570\u306e\u4e2d\u3067\u306fexpert.\u3092\u3064\u3051\u306a\u3044\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3057\u3001\u305d\u3063\u3061\u3067\u5bfe\u8c61\u3092\u6307\u5b9a\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u95a2\u6570\u5168\u4f53\u3068\u3057\u3066\u306f\u4e0d\u8981\u3068\u8003\u3048\u308c\u3070\u826f\u3044\u3067\u3057\u3087\u3046\u3002turnLeft()\u306f\u3064\u3051\u308b\u306e\u306bturnLock()\u306f\u3064\u3051\u306a\u3044\u3001\u3068\u3044\u3046\u306e\u304c\u6c17\u6301\u3061\u60aa\u3044\u3001\u3068\u3044\u3046\u65b9\u3082\u3044\u308b\u304b\u3082\u77e5\u308c\u306a\u3044\u3067\u3059\u304c\u3001\u624b\u9593\u304c\u6e1b\u308b\u3057\u3064\u3051\u306a\u3044\u65b9\u3092\u30aa\u30b9\u30b9\u30e1\u3057\u307e\u3059\u3002\u305f\u3076\u3093\u6b63\u5f0f\u306aSwift\u306e\u6587\u6cd5\u3068\u3057\u3066\u3082\u305d\u308c\u304c\u6b63\u3057\u3044\u306f\u305a\u3067\u3059\u3002<\/p>\n<script type=\"text\/javascript\">amzn_assoc_ad_type =\"responsive_search_widget\"; amzn_assoc_tracking_id =\"doguganprojec-22\"; amzn_assoc_marketplace =\"amazon\"; amzn_assoc_region =\"JP\"; amzn_assoc_placement =\"\"; amzn_assoc_search_type = \"search_widget\";amzn_assoc_width =\"500\"; amzn_assoc_height =\"400\"; amzn_assoc_default_search_category =\"\"; amzn_assoc_default_search_key =\"iPad\";amzn_assoc_theme =\"light\"; amzn_assoc_bg_color =\"FFFFFF\"; <\/script><script src=\"\/\/z-fe.amazon-adsystem.com\/widgets\/q?ServiceVersion=20070822&Operation=GetScript&ID=OneJS&WS=1&Marketplace=JP\"><\/script>","protected":false},"excerpt":{"rendered":"<p>\u3072\u3068\u3064\u306e\u95a2\u6570\u306b\u5f15\u6570\u30922\u3064\u4ee5\u4e0a\u3082\u305f\u305b\u308b\u3053\u3068\u3082\u51fa\u6765\u307e\u3059\u3002 \u30b9\u30c6\u30fc\u30ad.\u30aa\u30fc\u30c0\u30fc(\u713c\u304d\u52a0\u6e1b:\u30df\u30c7\u30a3\u30a2\u30e0, \u30bd\u30fc\u30b9:\u30ac\u30fc\u30ea\u30c3\u30af) \u3066\u306a\u3082\u3093\u3067\u3059\u3002 \u4eca\u56de\u306fturnLock\u3068\u3044\u3046\u95a2\u6570\u306b\u3001up\u3068numberOfTimes\u3068\u3044\u30462\u3064\u306e\u5909\u6570 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/do-gugan.com\/swift\/?p=131\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u30d1\u30e9\u30e1\u30fc\u30bf 2. \u95a2\u6570\u3092\u4f5c\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,12],"tags":[],"class_list":["post-131","post","type-post","status-publish","format-standard","hentry","category-learncode2","category-parameter"],"_links":{"self":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=131"}],"version-history":[{"count":5,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions"}],"predecessor-version":[{"id":138,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions\/138"}],"wp:attachment":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}