-
Notifications
You must be signed in to change notification settings - Fork 133
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 : 업무 중 대기 (리나) #19
Changes from 15 commits
e7669df
e0a49de
dfc7c4d
dd1f8f1
50568c6
45f521b
aef2237
e739d65
032fca2
8d12b14
67e050a
5ec44df
3fda98b
b8a57aa
2839647
37bce73
5849c49
4b3a68b
95adaf9
4c547e8
04d6910
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 |
---|---|---|
|
@@ -15,7 +15,8 @@ struct Clients { | |
guard let businessType = BusinessType.allCases.randomElement(), let priority = Client.Priority.allCases.randomElement() else { | ||
return | ||
} | ||
list.append(Client(waitingNumber: waitingNumber, businessType: businessType, priority: priority)) | ||
let clinet = Client(waitingNumber: waitingNumber, businessType: businessType, priority: priority) | ||
list.append(clinet) | ||
} | ||
} | ||
} | ||
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 |
---|---|---|
|
@@ -22,6 +22,8 @@ enum Message { | |
static let close = "업무가 마감되었습니다. 오늘 업무를 처리한 고객은 총 %d명이며, 총 업무시간은 %.2f초입니다." | ||
static let tellerStart = "%d번 %@고객 %@업무 시작" | ||
static let tellerFinish = "%d번 %@고객 %@업무 완료" | ||
static let loanStart = "%d번 %@고객 %@심사 시작" | ||
static let loanFinish = "%d번 %@고객 %@심사 완료" | ||
} | ||
|
||
enum BusinessType: CaseIterable, CustomStringConvertible { | ||
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. 보통 하나의 타입을 하나의 파일에 저장합니다. enum 들도 따로 파일로 저장하는 건 어떨까요? |
||
|
@@ -33,7 +35,7 @@ enum BusinessType: CaseIterable, CustomStringConvertible { | |
case .deposit: | ||
return 0.7 | ||
case .loan: | ||
return 1.1 | ||
return 0.3 | ||
} | ||
} | ||
|
||
|
@@ -47,7 +49,7 @@ enum BusinessType: CaseIterable, CustomStringConvertible { | |
} | ||
} | ||
|
||
enum BankError: Error, CustomStringConvertible { | ||
enum StringFormattingError: Error, CustomStringConvertible { | ||
case wrongInput | ||
case unknown | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// HeadOffice.swift | ||
// BankManagerConsoleApp | ||
// | ||
// Created by 임리나 on 2021/01/09. | ||
// | ||
|
||
import Foundation | ||
|
||
final class HeadOffice { | ||
static let shared = HeadOffice() | ||
private let neededTimeToJudgeLoan: TimeInterval = 0.5 | ||
let loanQueue: DispatchQueue = DispatchQueue(label: "HeadOffice") | ||
|
||
private init() {} | ||
|
||
func judgeLoan(for client: Client) { | ||
Dashboard.printStatus(for: client, about: Message.loanStart) | ||
Thread.sleep(forTimeInterval: self.neededTimeToJudgeLoan) | ||
Dashboard.printStatus(for: client, about: Message.loanFinish) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,14 +17,14 @@ func main() { | |
Dashboard.printMenu() | ||
|
||
guard let input = readLine(), let command = Menu(rawValue: input) else { | ||
print("\(BankError.wrongInput)") | ||
print("\(StringFormattingError.wrongInput)") | ||
continue | ||
} | ||
|
||
switch command { | ||
case .start: | ||
let randomNumber = Int.random(in: minClientCount...maxClientCount) | ||
let clients = Clients.init(count: randomNumber) | ||
let clients = Clients(count: randomNumber) | ||
bank.operateBank(teller: tellerCount, client: clients.list) | ||
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. bank.operateBank 라는 부분은 조금 어색한 것 같네요. |
||
case .end: | ||
isContinue = false | ||
|
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.
self. 를 지운 이유는 무엇인가요?