-
Notifications
You must be signed in to change notification settings - Fork 0
/
CSHBPrintMenu.swift
executable file
·84 lines (60 loc) · 2.69 KB
/
CSHBPrintMenu.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// CSHBPrintMenu.swift
// SeungHoBack_C0663173_Assignment
//
// Created by shoong on 2016-06-14.
// Copyright © 2016 SnowBack. All rights reserved.
//
import Foundation
class CSHBPrintMenu {
let mainMenu_ = CSHBMainMenu()
let insertMenu_ = CSHBInsertMenu()
let viewMenu_ = CSHBViewMenu()
let viewSubMenu_ = CSHBViewSubMenu()
var viewSubMenus_: [CSHBViewSubMenus] = []
let errorMenu_ = CSHBErrorMenu()
var subMenus_: [SHBMenus] = [CSHBSubMenus1(), CSHBSubMenus2(), CSHBSubMenus3(), CSHBSubMenus4(), CSHBSubMenus5(), CSHBSubMenus6()]
init() {
for index in 0...5 {
viewSubMenus_.append(CSHBViewSubMenus(index: index, menus: subMenus_[index]))
}
mainMenu_.aryPrintable = [errorMenu_, insertMenu_, viewMenu_, CSHBMainMenuExit()]
insertMenu_.aryPrintable = [errorMenu_, CSHBInsertNewStock(), CSHBInsertAllStock(), mainMenu_]
viewMenu_.aryPrintable = [errorMenu_, CSHBViewAllDomesticStocks(), CSHBViewAllForeignStocks(), viewSubMenu_, mainMenu_]
viewSubMenu_.aryPrintable = [errorMenu_, viewSubMenus_[0], viewSubMenus_[1], viewSubMenus_[2], viewSubMenus_[3], viewSubMenus_[4], viewSubMenus_[5], viewMenu_]
}
func Print() {
mainMenu_.printMenu()
}
}
class CSHBMainMenu: SHBPrintable {
var aryPrintable : [SHBPrintable] = []
func printMenu() {
var inputData = 0
while (inputData != aryPrintable.count) {
print("\n\n\n")
print("###################################################################")
print("####### Stock Management Application #######")
print("####### by SeungHo Back #######")
print("####### #######")
print("####### #######")
print("####### #######")
print("####### 1. Insert Stocks, 2. View Stocks, 3. exit #######")
print("###################################################################")
print(" Choose menu : ")
inputData = input(aryPrintable.count)
self.aryPrintable[inputData].printMenu()
}
}
}
class CSHBMainMenuExit: SHBPrintable {
func printMenu() {
print("Thank you for using this application")
exit(0)
}
}
class CSHBErrorMenu: SHBPrintable {
func printMenu() {
print("Wrong Input Values.. Try to input again")
}
}