diff --git a/.DS_Store b/.DS_Store index 46cc050..cf9f406 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/FizzBuzz/.DS_Store b/FizzBuzz/.DS_Store new file mode 100644 index 0000000..2253725 Binary files /dev/null and b/FizzBuzz/.DS_Store differ diff --git a/FizzBuzz/FizzBuzz.xcodeproj/project.pbxproj b/FizzBuzz/FizzBuzz.xcodeproj/project.pbxproj index fd26a1a..5e728c9 100644 --- a/FizzBuzz/FizzBuzz.xcodeproj/project.pbxproj +++ b/FizzBuzz/FizzBuzz.xcodeproj/project.pbxproj @@ -101,11 +101,11 @@ 9279C1ED28EF063300C0A266 /* FizzBuzz */ = { isa = PBXGroup; children = ( - 9279C1EE28EF063300C0A266 /* AppDelegate.swift */, - 9279C1F028EF063300C0A266 /* SceneDelegate.swift */, 9279C1F228EF063300C0A266 /* ViewController.swift */, - 9279C1F428EF063300C0A266 /* Main.storyboard */, + 9279C1F028EF063300C0A266 /* SceneDelegate.swift */, + 9279C1EE28EF063300C0A266 /* AppDelegate.swift */, 9279C1FA28EF063400C0A266 /* Assets.xcassets */, + 9279C1F428EF063300C0A266 /* Main.storyboard */, 9279C1FC28EF063400C0A266 /* LaunchScreen.storyboard */, 9279C1FF28EF063400C0A266 /* Info.plist */, 9279C1F728EF063300C0A266 /* FizzBuzz.xcdatamodeld */, @@ -441,7 +441,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = BWL68L4987; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = FizzBuzz/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; @@ -469,7 +469,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = BWL68L4987; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = FizzBuzz/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; diff --git a/FizzBuzz/FizzBuzz.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/FizzBuzz/FizzBuzz.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/FizzBuzz/FizzBuzz.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/FizzBuzz/FizzBuzz.xcodeproj/project.xcworkspace/xcuserdata/kodamatakumi.xcuserdatad/UserInterfaceState.xcuserstate b/FizzBuzz/FizzBuzz.xcodeproj/project.xcworkspace/xcuserdata/kodamatakumi.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..a41fe85 Binary files /dev/null and b/FizzBuzz/FizzBuzz.xcodeproj/project.xcworkspace/xcuserdata/kodamatakumi.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/FizzBuzz/FizzBuzz.xcodeproj/project.xcworkspace/xcuserdata/kodamatakumi.xcuserdatad/WorkspaceSettings.xcsettings b/FizzBuzz/FizzBuzz.xcodeproj/project.xcworkspace/xcuserdata/kodamatakumi.xcuserdatad/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..bbfef02 --- /dev/null +++ b/FizzBuzz/FizzBuzz.xcodeproj/project.xcworkspace/xcuserdata/kodamatakumi.xcuserdatad/WorkspaceSettings.xcsettings @@ -0,0 +1,14 @@ + + + + + BuildLocationStyle + UseAppPreferences + CustomBuildLocationType + RelativeToDerivedData + DerivedDataLocationStyle + Default + ShowSharedSchemesAutomaticallyEnabled + + + diff --git a/FizzBuzz/FizzBuzz.xcodeproj/xcuserdata/kodamatakumi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/FizzBuzz/FizzBuzz.xcodeproj/xcuserdata/kodamatakumi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..6679351 --- /dev/null +++ b/FizzBuzz/FizzBuzz.xcodeproj/xcuserdata/kodamatakumi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,6 @@ + + + diff --git a/FizzBuzz/FizzBuzz.xcodeproj/xcuserdata/kodamatakumi.xcuserdatad/xcschemes/xcschememanagement.plist b/FizzBuzz/FizzBuzz.xcodeproj/xcuserdata/kodamatakumi.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..701633e --- /dev/null +++ b/FizzBuzz/FizzBuzz.xcodeproj/xcuserdata/kodamatakumi.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + FizzBuzz.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/FizzBuzz/FizzBuzz/.DS_Store b/FizzBuzz/FizzBuzz/.DS_Store new file mode 100644 index 0000000..7ec3a4f Binary files /dev/null and b/FizzBuzz/FizzBuzz/.DS_Store differ diff --git a/FizzBuzz/FizzBuzz/Assets.xcassets/Background.colorset/Contents.json b/FizzBuzz/FizzBuzz/Assets.xcassets/Background.colorset/Contents.json new file mode 100644 index 0000000..b15071b --- /dev/null +++ b/FizzBuzz/FizzBuzz/Assets.xcassets/Background.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.339", + "green" : "0.724", + "red" : "0.185" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/FizzBuzz/FizzBuzz/Base.lproj/LaunchScreen.storyboard b/FizzBuzz/FizzBuzz/Base.lproj/LaunchScreen.storyboard index 865e932..c664e4f 100644 --- a/FizzBuzz/FizzBuzz/Base.lproj/LaunchScreen.storyboard +++ b/FizzBuzz/FizzBuzz/Base.lproj/LaunchScreen.storyboard @@ -1,8 +1,11 @@ - - + + + - + + + @@ -11,15 +14,20 @@ - + - + - + + + + + + diff --git a/FizzBuzz/FizzBuzz/ViewController.swift b/FizzBuzz/FizzBuzz/ViewController.swift index a44b706..dcf13c8 100644 --- a/FizzBuzz/FizzBuzz/ViewController.swift +++ b/FizzBuzz/FizzBuzz/ViewController.swift @@ -8,12 +8,99 @@ import UIKit class ViewController: UIViewController { - + //ラベルのインスタンス + let label = UILabel() + let labelCount = UILabel() + //カウンター + var count = 0 + + let num: Int = 100 + let FizzStr: String = "Fizz" + let BuzzStr: String = "Buzz" + let FizzBuzzStr: String = "FizzBuzz" + override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. + // スクリーンの横縦幅 + let screenWidth:CGFloat = self.view.frame.width + let screenHeight:CGFloat = self.view.frame.height + // ボタンのインスタンス + let button = UIButton() + //コンソールに表示するために呼び出す + self.fizzBuzzCount() + // ViewControllerの背景色 + self.view.backgroundColor = UIColor.init(named: "Background") + + // ボタンの位置とサイズを設定 + button.frame = CGRect(x:25, y:screenHeight/2, width:screenWidth-50, height:50) + // ボタンのタイトルを設定 + button.setTitle("Counter", for:UIControl.State.normal) + // タイトルの色 + button.setTitleColor(UIColor.black, for: .normal) + // ボタンのフォントサイズ + button.titleLabel?.font = UIFont.systemFont(ofSize: 36) + // 背景色 + button.backgroundColor = UIColor.white + // Viewにボタンを追加 + self.view.addSubview(button) + // タップされたときのaction + button.addTarget(self, + action: #selector(ViewController.buttonTapped(sender:)), + for: .touchUpInside) + + // ラベルのサイズを設定 + label.frame = CGRect(x:screenWidth/4, y:600, width:screenWidth/2, height:50); + labelCount.frame = CGRect(x:screenWidth/4, y:200, width:screenWidth/2, height:50); + // ラベルの文字を設定 + label.text = "0" + labelCount.text = "0" + // 文字を中央にalignする + label.textAlignment = NSTextAlignment.center + labelCount.textAlignment = NSTextAlignment.center + // ラベルのフォントサイズ + label.font = UIFont.systemFont(ofSize: 36) + labelCount.font = UIFont.systemFont(ofSize: 36) + // Viewにラベルを追加 + self.view.addSubview(label) + self.view.addSubview(labelCount) + } + + @objc func buttonTapped(sender: Any) { + count += 1 + label.text = fizzBuzzCheck(i: count) + labelCount.text = String(count) + } + + /* + funciton name: FizzBuzzCheck + return String + */ + func fizzBuzzCheck(i: Int) -> String { + switch (i%3, i%5) { + case (0, 0): + label.text = FizzBuzzStr + return FizzBuzzStr + case (0, _): + label.text = FizzStr + return FizzStr + case (_, 0): + label.text = BuzzStr + return BuzzStr + default: + label.text = String(i) + return String(i) + } + } + + /* + funciton name: FizzBuzzCount + return void + */ + func fizzBuzzCount() { + for x in 1...num { + print(fizzBuzzCheck(i: x)) + } } - - }