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

[Round1] Step3 - sy #997

Merged
merged 1 commit into from
Sep 25, 2024
Merged
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
7 changes: 5 additions & 2 deletions CodeStarterCamp_Week1/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@

import Foundation

drawIceCreamBody()
drawIceCreamBar()
drawPepero(stickLength: 4, bodyDecoration: "***", topping: "", bodyLength: 10)
drawPepero(stickLength: 4, bodyDecoration: "***", topping: "&", bodyLength: 12)
drawPepero(stickLength: 6, bodyDecoration: "|0|", topping: "#", bodyLength: 12)
drawPepero(stickLength: 4, bodyDecoration: "|0|", topping: "", bodyLength: 6)
drawPepero(stickLength: 4, bodyDecoration: "@@@", topping: "#", bodyLength: 10)
44 changes: 44 additions & 0 deletions CodeStarterCamp_Week1/step3.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// step3.swift
// CodeStarterCamp_Week1
//
// Created by jeseoyoung on 2024/09/14.
//

import Foundation

func drawPepero(stickLength: Int, bodyDecoration: String, topping: String = "", bodyLength: Int) {
print("""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정보를 출력해주는 것또한 따로 기능 분리를해서 이 안에 호출해주는 방법도 있습니다!
함수는 최대한 하나의 기능만 할 수있게 분리해주는게 좋아요 :)


<정보>
길이: \(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)
}
}

Binary file added ss_20_sy_week1-step3_flow_chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ss_20_sy_week1-step3_pepero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.