{"id":127,"date":"2018-11-11T13:47:04","date_gmt":"2018-11-11T04:47:04","guid":{"rendered":"https:\/\/dalomo.net\/blog\/?p=127"},"modified":"2018-11-17T23:41:13","modified_gmt":"2018-11-17T14:41:13","slug":"%e3%82%af%e3%83%a9%e3%82%b9%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f%e3%81%84","status":"publish","type":"post","link":"https:\/\/dalomo.net\/blog\/2018\/11\/11\/127\/","title":{"rendered":"\u30af\u30e9\u30b9\u4f7f\u3063\u3066\u307f\u305f\u3044"},"content":{"rendered":"<p>\u3084\u3063\u3066\u307f\u3088\u3046\u3002\u66f8\u3044\u305f\u306e\u3082\u3063\u305f\u3044\u306a\u3044\u3051\u3069\u3002<\/p>\n<h2>\u7d06\u4f59\u66f2\u6298<\/h2>\n<h3>\u30af\u30e9\u30b9\u4f5c\u308a<\/h3>\n<p>\u30ea\u30d0\u30fc\u30b7\u4f5c\u3063\u305f\u4eba\u306e\u3084\u3064\u898b\u308b\u3068<\/p>\n<ul>\n<li>\u76e4<\/li>\n<li>\u30d7\u30ec\u30fc\u30e4\u30fc(\u4eba\u9593\u5bfe\u4eba\u9593\u3001\u4eba\u9593\u5bfe\u6a5f\u68b0)<\/li>\n<li>\u77f3<\/li>\n<li>\u30de\u30b9<\/li>\n<li>\u30eb\u30fc\u30eb<\/li>\n<\/ul>\n<p>\u3042\u305f\u308a\u304c\u5fc5\u8981\u307f\u305f\u3044\u3002<\/p>\n<p>\u81ea\u5206\u306e\u5834\u5408\u3001\u6a5f\u68b0\u306e\u30d7\u30ec\u30fc\u30e4\u30fc\u306a\u3093\u3066\u305d\u3082\u305d\u3082\u4f5c\u308c\u3093\u3057\u3001\u77f3\u306f\u25cb\u25cf\u3060\u3057\u3001\u30de\u30b9\u306fTextView\u3060\u3057\u3001\u4f5c\u308b\u306e\u76e4\u3050\u3089\u3044\u3067\u3044\u3063\u304b\u306a\u30fc\u3063\u3066\u3002\u30eb\u30fc\u30eb\u306f\u76e4\u306b\u542b\u3081\u308b\u3068\u304b\u3067\u304d\u3093\u3058\u3083\u306a\u3044\u304b\u306a\u3001\u3069\u3046\u306a\u306e\u304b\u306a\u3002<\/p>\n<h3>Board.java\u3092\u4f5c\u3063\u305f<\/h3>\n<pre>public class Board {\r\n    final int BLACK = 1;\r\n    final int WHITE = -1;\r\n    int PlayerTurn = 1;\r\n    private Context con;\r\n\r\n    public Board(Context context){\r\n        this.con = context;\r\n    }\r\n\r\n    public void putStone(TextView tv){\r\n        String stone = tv.getText().toString();\r\n\r\n        if(!stone.equals(\"\")){\r\n            Toast.makeText(this.con,\"\u305d\u3053\u306b\u77f3\u306f\u7f6e\u3051\u307e\u305b\u3093\", Toast.LENGTH_SHORT).show();\r\n        }else{\r\n            switch (PlayerTurn){\r\n                case(BLACK):\r\n                    tv.setText(\"\u25cf\");\r\n                    PlayerTurn = WHITE;\r\n                    break;\r\n                case(WHITE):\r\n                    tv.setText(\"\u25cb\");\r\n                    PlayerTurn = BLACK;\r\n                    break;\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<p>\u3044\u3061\u304a\u3053\u308c\u3067\u52d5\u3044\u305f\u3002\u3042\u3063\u3055\u308a\u3067\u304d\u305f\u308f\u3051\u3067\u306f\u306a\u304f\u304b\u306a\u308a\u624b\u9593\u53d6\u3063\u305f\u3002<\/p>\n<p>Toast\u8868\u793a\u3059\u308b\u306e\u306b\u5f15\u6570Context\u304c\u5fc5\u8981\u3067\u3001\u524d\u3068\u540c\u3058\u3088\u3046\u306bthis\u3063\u3066\u3084\u308b\u3068Board\u306e\u65b9\u3068\u8a8d\u8b58\u3055\u308c\u308b\u3002\u30e1\u30a4\u30f3\u306e\u65b9\u3067getApplicationContext()\u3057\u3066\u304a\u304d\u3001\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u3059\u308b\u6642\u306b\u5f15\u6570\u3067\u6e21\u3057\u3066\u3042\u3052\u308b\u3068\u3002\u307b\u3044\u3067Board\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3067\u53d7\u3051\u53d6\u3063\u3066\u3042\u3052\u308b\u3002\u306a\u308b\u307b\u3069\u306a\u3041\u3002\u8abf\u3079\u306a\u304d\u3083\u5206\u304b\u3093\u306a\u3044\u3088\u3002<\/p>\n<h3>Reversi.java\u3092\u5909\u66f4<\/h3>\n<p>\u30e1\u30a4\u30f3\u306e\u65b9\u3067New\u3059\u308b\u4f4d\u7f6e\u3082\u3088\u304f\u5206\u304b\u3063\u3066\u306a\u304b\u3063\u305f\u3002\u6700\u521dBoard\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306bTextView\u306e\u5f15\u6570\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u305f\u3057\u3001\u30e1\u30a4\u30f3\u306eocClick\u5185\u3067New\u3057\u3066\u3044\u305f\u3002\u3067\u3082\u305d\u308c\u3060\u3068Click\u3055\u308c\u308b\u305f\u3073\u306bNew\u3055\u308c\u3066\u3001New\u3055\u308c\u308b\u305f\u3073\u306bPlayerTurn\u304c\u521d\u671f\u5316\u3055\u308c\u3001\u9ed2\u77f3\u9023\u6253\u306b\u306a\u3063\u3066\u3044\u305f\u3002\u3060\u3082\u3093\u3067\u3058\u3083\u3042onCreate\u5185\u3067New\u3059\u308a\u3083\u3044\u3044\u306e\u304b\u3068\u3084\u3063\u3066\u307f\u305f\u3089\u3001\u4eca\u5ea6\u306fonClick\u5185\u3067Board\u304c\u4f7f\u3048\u306a\u3044\u3002\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5909\u6570\u306e\u5ba3\u8a00\u3068New\u3092\u3044\u3063\u307a\u3093\u306b\u3084\u3063\u3066\u305f\u306e\u304c\u539f\u56e0\u3060\u3063\u305f\u3002\u306e\u3067\u3001\u5909\u6570\u306e\u5ba3\u8a00\u3092\u982d\u3067\u3084\u3063\u3066\u3001onCreate\u5185\u3067New\u3059\u308b\u3068\u3001onClick\u5185\u3067\u3082\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u3001\u89e3\u6c7a\u3057\u305f\u3002\u8a66\u884c\u932f\u8aa4\u306e\u9023\u7d9a\u3067\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u30e1\u30a4\u30f3\u306eReversi.java\u306f<\/p>\n<h4>\u6700\u521d<\/h4>\n<pre>public class Reversi extends AppCompatActivity {\r\n    Board board;<\/pre>\n<h4>onCreate\u5185<\/h4>\n<pre>Context context = getApplicationContext();\r\nboard = new Board(context);<\/pre>\n<h4>onClick\u5185<\/h4>\n<pre>TextView tv = findViewById(id);\r\nboard.putStone(tv);<\/pre>\n<p>\u3068\u66f8\u3051\u305f\u3002<\/p>\n<p>\u306a\u3093\u3060\u308d\u306a\u3001\u3084\u3063\u3071\u308a\u30b9\u30b3\u30fc\u30d7\u304c\u3061\u3083\u3093\u3068\u5206\u304b\u3063\u3066\u306a\u3044\u304b\u3089\u3053\u3093\u306a\u624b\u9593\u53d6\u308b\u306e\u304b\u306a\u3002\u305d\u308c\u3060\u3051\u3058\u3083\u306a\u3044\u3093\u3060\u308d\u3046\u3051\u3069\u3082\u3002\u3046\u30fc\u3080\u3002<\/p>\n<p>PlayerTurn\u3063\u3066\u3053\u3053\u3067\u3044\u3044\u3093\u3060\u308d\u3046\u304b\u3001Player\u3063\u3066\u4ed8\u3044\u3066\u308b\u3057\u3001Player\u30af\u30e9\u30b9\u3092\u4f5c\u3063\u305f\u307b\u3046\u304c\u3044\u3044\u306e\u304b\u306a\u3041\u3002\u3067\u3082\u624b\u756a\u7ba1\u7406\u3063\u3066\u76e4\u9762\u306e\u4ed5\u4e8b\u306a\u6c17\u3082\u3059\u308b\u3057\u3002<\/p>\n<p>\u3042\u3068\u30af\u30e9\u30b9\u3092\u4f5c\u3063\u305f\u304b\u3089\u3068\u3044\u3063\u3066\u3001\u305d\u3053\u307e\u3067\u697d\u306b\u306a\u3063\u305f\u306e\u304b\u3068\u3044\u3046\u3068\u305d\u3046\u3067\u3082\u306a\u3044\u3088\u3046\u306a\u6c17\u304c\u3059\u308b\u3002\u30e1\u30a4\u30f3\u306f\u898b\u6674\u3089\u3057\u304c\u826f\u304f\u306a\u3063\u305f\u3051\u3069\u3001Board\u306e\u65b9\u306f\u3053\u3063\u304b\u3089\u3061\u3087\u3063\u3068\u3065\u3064\u8db3\u3057\u3066\u304f\u308f\u3051\u3060\u3082\u3093\u306d\u3001\u3084\u308b\u3053\u3068\u306f\u4e00\u7dd2\u306a\u3093\u3058\u3083\u306a\u3044\u3060\u308d\u3046\u304b\u3002\u3053\u306e\u307e\u307e\u3044\u304f\u3068putStone\u304c\u80a5\u5927\u5316\u3057\u3066\u3044\u304f\u3088\u3046\u306a\u6c17\u304c\u3057\u3066\u306a\u3089\u306a\u3044\u3002\u307e\u3041\u305b\u3063\u304b\u304f\u4f5c\u3063\u305f\u3093\u3060\u3057\u3053\u308c\u3092\u4f7f\u3063\u3066\u3044\u3053\u3046\u3001\u305d\u3046\u3057\u3088\u3046\u3002<\/p>\n<h3>\u53c2\u8003<\/h3>\n<p><a href=\"http:\/\/rui-phone.hatenablog.com\/entry\/2014\/09\/23\/213642\">http:\/\/rui-phone.hatenablog.com\/entry\/2014\/09\/23\/213642<\/a><\/p>\n<p><a href=\"http:\/\/kmaebashi.com\/programmer\/object\/othello.html\">http:\/\/kmaebashi.com\/programmer\/object\/othello.html<\/a><\/p>\n<p><a href=\"http:\/\/d.hatena.ne.jp\/prime503\/20100106\/1262767141\">http:\/\/d.hatena.ne.jp\/prime503\/20100106\/1262767141<\/a><\/p>\n<p><a href=\"http:\/\/www.aerith.net\/design\/othello-j.html\">http:\/\/www.aerith.net\/design\/othello-j.html<\/a><\/p>\n<p><a href=\"https:\/\/akira-watson.com\/android\/class-method.html\">https:\/\/akira-watson.com\/android\/class-method.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3084\u3063\u3066\u307f\u3088\u3046\u3002\u66f8\u3044\u305f\u306e\u3082\u3063\u305f\u3044\u306a\u3044\u3051\u3069\u3002 \u7d06\u4f59\u66f2\u6298 \u30af\u30e9\u30b9\u4f5c\u308a \u30ea\u30d0\u30fc\u30b7\u4f5c\u3063\u305f\u4eba\u306e\u3084\u3064\u898b\u308b\u3068 \u76e4 \u30d7\u30ec\u30fc\u30e4\u30fc(\u4eba\u9593\u5bfe\u4eba\u9593\u3001\u4eba\u9593\u5bfe\u6a5f\u68b0) \u77f3 \u30de\u30b9 \u30eb\u30fc\u30eb \u3042\u305f\u308a\u304c\u5fc5\u8981\u307f\u305f\u3044\u3002 \u81ea\u5206\u306e\u5834\u5408\u3001\u6a5f\u68b0\u306e\u30d7\u30ec\u30fc\u30e4\u30fc\u306a\u3093\u3066\u305d\u3082\u305d\u3082\u4f5c &hellip; <a href=\"https:\/\/dalomo.net\/blog\/2018\/11\/11\/127\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[8],"tags":[3,6,4,13],"class_list":["post-127","post","type-post","status-publish","format-standard","hentry","category-8","tag-android","tag-androidstudio","tag-4","tag-13"],"_links":{"self":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/comments?post=127"}],"version-history":[{"count":2,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/127\/revisions"}],"predecessor-version":[{"id":129,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/127\/revisions\/129"}],"wp:attachment":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/media?parent=127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/categories?post=127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/tags?post=127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}