-
Notifications
You must be signed in to change notification settings - Fork 132
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
은행창구 매니저 [Step3] 토이, 쥬봉이 #330
base: ic_10_toy123
Are you sure you want to change the base?
Changes from 8 commits
77a0506
d128f7e
d5ba69a
3d5f009
108e79b
4e3b66e
0df2dae
bef067d
bd60560
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// | ||
// Banking.swift | ||
// | ||
// | ||
// Created by jyubong, Toy on 11/22/23. | ||
// | ||
|
||
public enum Banking: String, CaseIterable { | ||
case deposit = "예금" | ||
case loan = "대출" | ||
} | ||
Comment on lines
+8
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
public protocol CustomerNumbering { | ||
var number: UInt { get } | ||
var banking: Banking? { get } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 굳이 옵셔널일 필요가 있을까요? |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,20 +8,29 @@ import Foundation | |
import BankManager | ||
|
||
struct BankClerk: CustomerReceivable { | ||
private let pace = 0.7 | ||
private let work: Banking | ||
private var pace: Double { | ||
switch work { | ||
case .deposit: | ||
return 0.7 | ||
case .loan: | ||
return 1.1 | ||
} | ||
} | ||
Comment on lines
+11
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저는 이 정보가 은행원보다는 |
||
private let startWork: (String) -> Void | ||
private let endWork: (String) -> Void | ||
|
||
init(startWork: @escaping (String) -> Void = { print($0) }, endWork: @escaping (String) -> Void = { print($0) }) { | ||
init(work: Banking, startWork: @escaping (String) -> Void = { print($0) }, endWork: @escaping (String) -> Void = { print($0) }) { | ||
self.work = work | ||
self.startWork = startWork | ||
self.endWork = endWork | ||
} | ||
|
||
func receive(customer: Customer) { | ||
let number = customer.number | ||
|
||
startWork("\(number)번 고객 업무 시작") | ||
startWork("\(number)번 고객 \(work.rawValue)업무 시작") | ||
Thread.sleep(forTimeInterval: pace) | ||
endWork("\(number)번 고객 업무 종료") | ||
endWork("\(number)번 고객 \(work.rawValue)업무 종료") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
한번에 최대 실행될 수 있는 작업의 수는 3개인데, 생성된 쓰레드의 수는 3개보다 훨씬 많네요.
총 3개의 쓰레드만 생성하고싶다면 어떻게 해야할까요?