Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fizz buzz1020239 #39

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
Binary file added FizzBuzz/.DS_Store
Binary file not shown.
10 changes: 5 additions & 5 deletions FizzBuzz/FizzBuzz.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildLocationStyle</key>
<string>UseAppPreferences</string>
<key>CustomBuildLocationType</key>
<string>RelativeToDerivedData</string>
<key>DerivedDataLocationStyle</key>
<string>Default</string>
<key>ShowSharedSchemesAutomaticallyEnabled</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "0CF7191C-91A3-4836-878F-F6800BF0EB77"
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>FizzBuzz.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Binary file added FizzBuzz/FizzBuzz/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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
}
}
20 changes: 14 additions & 6 deletions FizzBuzz/FizzBuzz/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_0" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -11,15 +14,20 @@
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="390" height="844"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
<point key="canvasLocation" x="52.307692307692307" y="374.64454976303318"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
93 changes: 90 additions & 3 deletions FizzBuzz/FizzBuzz/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}


}