-
Notifications
You must be signed in to change notification settings - Fork 0
/
CSHBViewSubMenu.swift
executable file
·116 lines (81 loc) · 3.13 KB
/
CSHBViewSubMenu.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//
// CSHBViewSubMenu.swift
// SeungHoBack_C0663173_Assignment
//
// Created by shoong on 2016-06-16.
// Copyright © 2016 SnowBack. All rights reserved.
//
import Foundation
public let aryMenuText: [String] = [ "1. Display stock information with the lowest value",
"2. Display stock with the highest value",
"3. Display the most profitable stock",
"4. Display the least profitable stock",
"5. List all stocks sorted by company name(A-Z)",
"6. List all stocks sorted by from the lowest value to the highest value" ]
class CSHBViewSubMenu: SHBPrintable {
var aryPrintable : [SHBPrintable] = []
func printMenu() {
var inputData = 0
while (inputData != aryPrintable.count) {
print("\n\n\n")
print("###################################################################")
print("############ View Sub Menu ############")
print("###################################################################")
for text in aryMenuText {
print("##### \(text)")
}
print("##### 7. Return to View Menu")
print("###################################################################")
print(" Choose menu : ")
inputData = input(aryPrintable.count)
self.aryPrintable[inputData].printMenu()
}
}
}
class CSHBViewSubMenus: SHBPrintable {
var menus_ : SHBMenus
var nIndex_ = 0
init (index: Int, menus: SHBMenus) {
nIndex_ = index
menus_ = menus
}
func printMenu() {
print("\n\n\n")
print("###################################################################")
print("##### \(aryMenuText[nIndex_])")
print("###################################################################")
menus_.printSubMenus()
print("Press any key to return View Sub Menu")
input(0)
}
}
class CSHBSubMenus1: SHBMenus {
func printSubMenus() {
CSHBStockManagement.singletonInstance.printDisplayValues(true, isAll: false)
}
}
class CSHBSubMenus2: SHBMenus {
func printSubMenus() {
CSHBStockManagement.singletonInstance.printDisplayValues(false, isAll: false)
}
}
class CSHBSubMenus3: SHBMenus {
func printSubMenus() {
CSHBStockManagement.singletonInstance.printDisplayProfitable(false)
}
}
class CSHBSubMenus4: SHBMenus {
func printSubMenus() {
CSHBStockManagement.singletonInstance.printDisplayProfitable(true)
}
}
class CSHBSubMenus5: SHBMenus {
func printSubMenus() {
CSHBStockManagement.singletonInstance.printDisplayCompanyName(true)
}
}
class CSHBSubMenus6: SHBMenus {
func printSubMenus() {
CSHBStockManagement.singletonInstance.printDisplayValues(true, isAll: true)
}
}