{"id":178,"date":"2024-09-17T11:12:41","date_gmt":"2024-09-17T11:12:41","guid":{"rendered":"https:\/\/wp.shimayugu.jp\/?p=178"},"modified":"2024-10-11T08:55:52","modified_gmt":"2024-10-11T08:55:52","slug":"%e6%96%b0swift%e3%81%a7%e8%a1%8c%e3%81%93%e3%81%86-%e7%ac%ac%ef%bc%91%ef%bc%95%e5%9b%9e%e3%80%8c%e3%83%88%e3%83%a9%e3%83%b3%e3%83%97%ef%bc%95%e3%80%8d%e3%80%80%e7%94%b0%e9%83%a8%e4%ba%95%e4%bf%9d","status":"publish","type":"post","link":"https:\/\/wp.shimayugu.jp\/?p=178","title":{"rendered":"\u65b0Swift\u3067\u884c\u3053\u3046&#8230;\u7b2c\uff11\uff15\u56de\u300c\u30c8\u30e9\u30f3\u30d7\uff15\u300d\u3000\u7530\u90e8\u4e95\u4fdd"},"content":{"rendered":"\n<p><a href=\"https:\/\/shimayugu.sakura.ne.jp\/?p=2298\">\u76ee\u6b21<\/a>\u3000<a href=\"https:\/\/wp.shimayugu.jp\/?p=641\">\u89e3\u8aac\u7de8<\/a><\/p>\n\n\n\n<p>\u3000\u524d\u56de\u306e\u554f\u984c\u306f\u3001\u2663\ufe0f\u4ee5\u5916\u306e\u30de\u30fc\u30af\u306e\u30ab\u30fc\u30c9\u3082JK\u3092\u9664\u3044\u3066\u3059\u3079\u3066\u51fa\u3059\u3068\u3044\u3046\u3082\u306e\u3067\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u3000\u524d\u56de\u306e\u554f\u984c\u306e\u7b54\u3048\u306e\u4e00\u3064\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-swift\" data-lang=\"Swift\" data-line=\"19-20,32\" data-show-lang=\"1\"><code>\/\/\n\/\/  ViewController.swift\n\/\/  Card\n\/\/\n\/\/  Created by \u4fdd Tabei on 2024\/09\/01.\n\/\/\n\nimport UIKit\n\nclass ViewController: UIViewController {\n\n    @IBOutlet weak var lblCard: UILabel!\n    @IBOutlet weak var lblCount: UILabel!\n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n        \/\/ Do any additional setup after loading the view.\n        for i in 0 ..&lt; EnumCard.Count {\n            let lbl = UILabel(frame: CGRectMake(0, 0, 50, 21))\n            lbl.center = CGPointMake(120 + 50 * CGFloat(i \/ 13), 100 + CGFloat(i % 13) * 30)\n            lbl.textAlignment = NSTextAlignment.center\n            lbl.text = &quot;\u2b1b\ufe0f&quot;\n            eachCard += [lbl]\n            self.view.addSubview(lbl)\n        }\n   }\n\n    let mark: [String] = [&quot;\u2663\ufe0f&quot;,&quot;\u2666\ufe0f&quot;,&quot;\u2764\ufe0f&quot;,&quot;\u2660\ufe0f&quot;]\n    let number: [String] = [&quot;A&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;5&quot;,&quot;6&quot;,&quot;7&quot;,&quot;8&quot;,&quot;9&quot;,&quot;T&quot;,&quot;J&quot;,&quot;Q&quot;,&quot;K&quot;]\n\n    enum EnumCard {\n        static let Count = 52\n    }\n    \n    var check = [Bool](repeating: false, count: EnumCard.Count)\n\n    var count = EnumCard.Count\n    \n    var eachCard: [UILabel] = []\n\n    @IBAction func btnGoTouch(_ sender: Any) {\n        if count == 0 {\n            for i in 0 ..&lt; EnumCard.Count\n            {\n                check[i] = false\n                eachCard[i].text = &quot;\u2b1b\ufe0f&quot;\n            }\n            \n            let alert = UIAlertController()\n            alert.title = &quot;\u521d\u671f\u5316&quot;\n            alert.message = &quot;\u30ab\u30fc\u30c9\u3092\u914d\u308a\u76f4\u3057\u307e\u3059&quot;\n            alert.addAction(UIAlertAction(title: &quot;OK&quot;, style: .default))\n            present(alert, animated: true, completion: nil)\n            count = EnumCard.Count\n        }\n        else\n        {\n            var card = 0\n            let randInt = Int.random(in: 0 ..&lt; count)\n            for i in 0 ... randInt {\n                while check[card] {\n                    card += 1\n                }\n                if i &lt; randInt {\n                    card += 1\n                }\n            }\n            \n            check[card] = true\n            \n            count -= 1\n            lblCount.text = count.description\n            \n            if card == 52 {\n                lblCard.text = &quot;JK&quot;\n            } else {\n                lblCard.text = mark[card \/ 13] + number[card % 13]\n            }\n            \n            eachCard[card].text = lblCard.text\n        }\n    }\n}<\/code><\/pre><\/div>\n\n\n\n<p>\u3000\u3053\u306e\u3088\u3046\u306b\u5927\u91cf\u306e\u30e9\u30d9\u30eb\u3092\u8cbc\u308b\u6642\u306f\u3001\u30b3\u30fc\u30c9\u3067\u751f\u6210\u3057\u3066\u3057\u307e\u3063\u305f\u65b9\u304c\u697d\u3067\u3059\u3002\u3055\u3066\u6b21\u56de\u304b\u3089\u30dd\u30fc\u30ab\u30fc\u306b\u5165\u308a\u307e\u3059\u3002\u554f\u984c\u3067\u3059\u30025\u679a\u306e\u30ab\u30fc\u30c9\u3092\u91cd\u8907\u7121\u304f\u914d\u3063\u3066\u4e0b\u3055\u3044\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/shimayugu.sakura.ne.jp\/?p=2298\">\u76ee\u6b21<\/a>\u3000<a href=\"https:\/\/wp.shimayugu.jp\/?p=641\">\u89e3\u8aac\u7de8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6b21\u3000\u89e3\u8aac\u7de8 \u3000\u524d\u56de\u306e\u554f\u984c\u306f\u3001\u2663\ufe0f\u4ee5\u5916\u306e\u30de\u30fc\u30af\u306e\u30ab\u30fc\u30c9\u3082JK\u3092\u9664\u3044\u3066\u3059\u3079\u3066\u51fa\u3059\u3068\u3044\u3046\u3082\u306e\u3067\u3057\u305f\u3002 \u3000\u524d\u56de\u306e\u554f\u984c\u306e\u7b54\u3048\u306e\u4e00\u3064\u3067\u3059\u3002 \u3000\u3053\u306e\u3088\u3046\u306b\u5927\u91cf\u306e\u30e9\u30d9\u30eb\u3092\u8cbc\u308b\u6642\u306f\u3001\u30b3\u30fc\u30c9\u3067\u751f\u6210\u3057\u3066\u3057\u307e\u3063\u305f\u65b9\u304c\u697d\u3067\u3059\u3002\u3055\u3066\u6b21\u56de\u304b\u3089\u30dd\u30fc\u30ab [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-178","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/wp.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts\/178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=178"}],"version-history":[{"count":7,"href":"https:\/\/wp.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts\/178\/revisions"}],"predecessor-version":[{"id":772,"href":"https:\/\/wp.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts\/178\/revisions\/772"}],"wp:attachment":[{"href":"https:\/\/wp.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}