diff --git a/CodeStarterCamp_Week1/main.swift b/CodeStarterCamp_Week1/main.swift index 5878a146..ffa664e2 100644 --- a/CodeStarterCamp_Week1/main.swift +++ b/CodeStarterCamp_Week1/main.swift @@ -8,5 +8,4 @@ import Foundation -drawIceCreamBody() -drawIceCreamBar() +drawPepero(stickLength: 4, bodyDecoration: "*", topping: "!", bodyLength: 10) diff --git a/CodeStarterCamp_Week1/step3.swift b/CodeStarterCamp_Week1/step3.swift new file mode 100644 index 00000000..05c8d0a6 --- /dev/null +++ b/CodeStarterCamp_Week1/step3.swift @@ -0,0 +1,43 @@ +// +// step3.swift +// CodeStarterCamp_Week1 +// +// Created by jeseoyoung on 2024/09/14. +// + +import Foundation + +func drawPepero(stickLength: Int, bodyDecoration: String, topping: String = "", bodyLength: Int) { + print(""" + <정보> + 길이: \(bodyLength) + 몸통: \(bodyDecoration) + 토핑: \(topping) + 막대길이: \(stickLength) + + """) + + printBody(length: bodyLength, decoration: bodyDecoration, topping: topping) + drawPeperoStick(length: stickLength) +} + +func drawPeperoStick(length: Int) { + for _ in 1...length { + print(" | |") + } +} + +func printPeperoBodyAndToppings(decoration: String, topping: String) { + if topping.count == 0 { + print(" ", topping, decoration, topping, separator: "") + } else { + print(topping, decoration, topping, separator: "") + } +} + +func printBody(length: Int, decoration: String, topping: String) { + for _ in 1...length { + printPeperoBodyAndToppings(decoration: decoration, topping: topping) + } +} + diff --git a/ss_20_sy_week1-step3_flow_chart.png b/ss_20_sy_week1-step3_flow_chart.png new file mode 100644 index 00000000..babb21b9 Binary files /dev/null and b/ss_20_sy_week1-step3_flow_chart.png differ diff --git a/ss_20_sy_week1-step3_pepero.png b/ss_20_sy_week1-step3_pepero.png new file mode 100644 index 00000000..857dec31 Binary files /dev/null and b/ss_20_sy_week1-step3_pepero.png differ