Skip to content

Commit

Permalink
주문에 따른 빼빼로 그리기 코드 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
forseaest committed Nov 26, 2023
1 parent 183adda commit 2839331
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CodeStarterCamp_Week1.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
0648A9852B13457F009A20A7 /* step3.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0648A9842B13457F009A20A7 /* step3.swift */; };
34811DAF274B938F00A1E994 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34811DAE274B938F00A1E994 /* main.swift */; };
/* End PBXBuildFile section */

Expand All @@ -23,6 +24,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
0648A9842B13457F009A20A7 /* step3.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = step3.swift; sourceTree = "<group>"; };
34811DAB274B938F00A1E994 /* CodeStarterCamp_Week1 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CodeStarterCamp_Week1; sourceTree = BUILT_PRODUCTS_DIR; };
34811DAE274B938F00A1E994 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -58,6 +60,7 @@
isa = PBXGroup;
children = (
34811DAE274B938F00A1E994 /* main.swift */,
0648A9842B13457F009A20A7 /* step3.swift */,
);
path = CodeStarterCamp_Week1;
sourceTree = "<group>";
Expand Down Expand Up @@ -120,6 +123,7 @@
buildActionMask = 2147483647;
files = (
34811DAF274B938F00A1E994 /* main.swift in Sources */,
0648A9852B13457F009A20A7 /* step3.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
7 changes: 5 additions & 2 deletions CodeStarterCamp_Week1/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ func makeStick(stickLength: Int) {
}
}

makeIcecream(icecreamLength: 8)
makeStick(stickLength: 4)
//makeIcecream(icecreamLength: 8)
//makeStick(stickLength: 4)

makeOrder()
makeCustomizedPepero()
54 changes: 54 additions & 0 deletions CodeStarterCamp_Week1/step3.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// step3.swift
// CodeStarterCamp_Week1
//
// Created by H on 11/26/23.
//

import Foundation

var entireLength: Int = 0
var body: String = ""
var topping: String = ""
var stickLength: Int = 0

func makeOrder() {
print("<정보>")

print("길이: ", terminator: "")
entireLength = Int(readLine() ?? "") ?? 0

print("몸통: ", terminator: "")
body = readLine() ?? ""

print("토핑: ", terminator: "")
topping = readLine() ?? ""

print("막대길이: ", terminator: "")
stickLength = Int(readLine() ?? "") ?? 0

print("")
}

func makeCustomizedPepero() {
makeCustomizedPeperoBody()
makeCustomizedPeperoStick()
}

func makeCustomizedPeperoBody() {
if topping == "" {
for _ in 0..<entireLength {
print(" \(topping)\(body)\(topping)")
}
} else {
for _ in 0..<entireLength {
print("\(topping)\(body)\(topping)")
}
}
}

func makeCustomizedPeperoStick() {
for _ in 0..<stickLength {
print(" | | ")
}
}

0 comments on commit 2839331

Please sign in to comment.