-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenu.cs
154 lines (136 loc) · 4.28 KB
/
Menu.cs
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
using System;
using System.Collections.Generic;
namespace ParkingSpace
{
static class Menu
{
static Parking park = Parking.Create;
private static int index = 0;
private static string drawMenu(List<string> items)
{
for (int i = 0; i < items.Count; i++)
{
if (i == index)
{
Console.BackgroundColor = ConsoleColor.Gray;
Console.ForegroundColor = ConsoleColor.Black;
Console.WriteLine(items[i]);
}
else
{
Console.WriteLine(items[i]);
}
Console.ResetColor();
}
ConsoleKeyInfo ckey = Console.ReadKey();
if (ckey.Key == ConsoleKey.DownArrow)
{
if (index == items.Count - 1)
{
//index = 0; //Remove the comment to return to the topmost item in the list
}
else { index++; }
}
else if (ckey.Key == ConsoleKey.UpArrow)
{
if (index <= 0)
{
//index = menuItem.Count - 1; //Remove the comment to return to the item in the bottom of the list
}
else { index--; }
}
else if (ckey.Key == ConsoleKey.Enter)
{
return items[index];
}
else
{
return "";
}
Console.Clear();
return "";
}
public static void Start()
{
List<string> menuItems = new List<string>() {
"Add new car",
"Remove car",
"Show car",
"Add cash to car",
"Show pricelist",
"Show current profit",
"Remaining count",
"Show all transactions",
"Preview minute transactions",
"Exit"
};
Console.CursorVisible = false;
while (true)
{
string selectedMenuItem = Menu.drawMenu(menuItems);
switch(selectedMenuItem)
{
case "Add new car":
{
Console.Clear();
park.AddCar();
break;
}
case "Remove car":
{
Console.Clear();
park.RemoveCar();
break;
}
case "Show car":
{
Console.Clear();
park.ShowCar();
break;
}
case "Show pricelist":
{
Console.Clear();
park.ShowPrice();
break;
}
case "Show current profit":
{
Console.Clear();
park.ShowProfit();
break;
}
case "Show all transactions":
{
Console.Clear();
park.ShowAllTransactions();
break;
}
case "Preview minute transactions":
{
Console.Clear();
park.PrevMinuteTransactions();
break;
}
case "Remaining count":
{
Console.Clear();
park.RemainingCount();
break;
}
case "Add cash to car":
{
Console.Clear();
park.AddCash();
break;
}
case "Exit":
{
Environment.Exit(0);
break;
}
}
}
}
}
}