-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconsole.txt
More file actions
264 lines (252 loc) · 10.1 KB
/
Copy pathconsole.txt
File metadata and controls
264 lines (252 loc) · 10.1 KB
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
package org.millardps.InventoryManagement;
import java.io.*;
import java.util.*;
public class Console {
Scanner scanner = new Scanner(System.in);
private File p = new File("pmem.txt");
private File m = new File("mem.txt");
public String[] letters = new String[]{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "_", "-", "=", "+", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", " "};
public String[] shifted = new String[]{"m", "l", "8", "q", "A", "P", "R", "W", "C", "h", "n", "k", "1", "7", "z", "B", "o", "9", "2", "g", "f", "6", "p", "O", "0", "a", "e", "3", "j", "Q", "V", "-", "4", "=", "b", "d", "J", "N", " ", "X", "", "M", "I", "U", "J", "i", "5", "y", "c", "w", "*", "T", "$", "%", "S", "v", "^", "L", "+", "&", "Y", "u", "#", "D", "_", "", "r", "Z", "H", "!", "s", "@", "F", "t", "x", "G", "E"};
private String command;
private ArrayList<String> tmp = new ArrayList();
Console() {
popArray();
System.out.println("Oxi Inventory Management [Version Alpha 0.1]");
System.out.println("(c) 2016 MidWestOxidation Enterprise. All rights reserved.");
System.out.println();
nextCommand();
}
public void nextCommand() {
System.out.print(">");
command = scanner.nextLine();
try {
if (command.toLowerCase().equals("help")) {
help();
} else if (command.toLowerCase().substring(0, 3).equals("add")) {
if (command.length() > 3) {
add(command);
} else {
System.out.println("Appends items to the inventory.");
System.out.println();
System.out.println("USAGE:");
System.out.println("add [/N] [/C] [/P] [/D]");
System.out.println();
System.out.println(" /N Item name.");
System.out.println(" /C Item category.");
System.out.println(" /P Item price.");
System.out.println(" /D Item description.");
System.out.println(" /Q Item quantity.");
nextCommand();
}
} else if (command.toLowerCase().equals("about")) {
about();
} else if (command.toLowerCase().equals("search")) {
search();
} else if (command.toLowerCase().equals("sell")) {
sell();
} else if (command.toLowerCase().equals("clear")) {
clear();
} else if (command.toLowerCase().equals("exit")) {
writeArray();
} else if (command.toLowerCase().substring(0, 3).equals("cat")) {
System.out.println(command.substring(4, command.length()));
nextCommand();
} else if (command.toLowerCase().equals("passwd")) {
newPass();
nextCommand();
}
else{
System.out.println("'" + command + "' is not recognized as an internal command.");
nextCommand();
}
}
catch (StringIndexOutOfBoundsException var1_1) {
System.out.println("'" + command + "' is not recognized as an internal command.");
nextCommand();
}
}
public void help() {
System.out.println("For more specific information regarding a command, please type the command name.");
System.out.println("ADD Appends items to the inventory.");
System.out.println("SEARCH Searches the inventory for items.");
System.out.println("SELL Removes items from inventory, modifies drawer amount.");
System.out.println("CAT Prints the input to the console");
System.out.println("PASSWD Reset your password.");
System.out.println("ABOUT About this product.");
System.out.println("CLEAR Clears the console.");
System.out.println("EXIT Closes the current session");
nextCommand();
}
public void add(String string) {
int n;
String string2 = "";
if (string.contains("/n")) {
n = 0;
while (string.substring(n).contains("/n")) {
++n;
}
String string3 = string.substring(n + 1);
n = string3.length();
while (string3.substring(0, n).contains("/")) {
--n;
}
string2 = string2 + string3.substring(0, n).trim() + "-";
} else {
string2 = string2 + "null-";
}
if (string.contains("/q")) {
n = 0;
while (string.substring(n).contains("/q")) {
++n;
}
String string4 = string.substring(n + 1);
n = string4.length();
while (string4.substring(0, n).contains("/")) {
--n;
}
string2 = string2 + string4.substring(0, n).trim() + "-";
} else {
string2 = string2 + "null-";
}
if (string.contains("/c")) {
n = 0;
while (string.substring(n).contains("/c")) {
++n;
}
String string5 = string.substring(n + 1);
n = string5.length();
while (string5.substring(0, n).contains("/")) {
--n;
}
string2 = string2 + string5.substring(0, n).trim() + "-";
} else {
string2 = string2 + "null-";
}
if (string.contains("/p")) {
n = 0;
while (string.substring(n).contains("/p")) {
++n;
}
String string6 = string.substring(n + 1);
n = string6.length();
while (string6.substring(0, n).contains("/")) {
--n;
}
string2 = string2 + string6.substring(0, n).trim() + "-";
} else {
string2 = string2 + "null-";
}
if (string.contains("/d")) {
n = 0;
while (string.substring(n).contains("/d")) {
++n;
}
String string7 = string.substring(n + 1);
n = string7.length();
while (string7.substring(0, n).contains("/")) {
--n;
}
string2 = string2 + string7.substring(0, n).trim();
} else {
string2 = string2 + "null";
}
tmp.add(string2);
System.out.println("Item added to inventory: " + string2 + ".");
nextCommand();
}
public void search() {
for (int i = 0; i < tmp.size(); ++i) {
System.out.println(tmp.get(i));
}
nextCommand();
}
public void about() {
try {
new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor();
}
catch (InterruptedException var1_1) {
System.out.println("InterruptedException");
}
catch (IOException var1_2) {
System.out.println("IOException");
}
System.out.println("Oxi Inventory Management is a product developed by MidWestOxidation Enterprise (c) 2016.");
System.out.println("The intended purpose was to create a simple, secure, and powerful interface that can be used to manage small businesses.");
System.out.println("For more information, please visit http://www.midwestoxidation.com/oxi");
System.out.println();
nextCommand();
}
public void sell() {
System.out.println("This feature has not yet been implemented");
nextCommand();
}
public void clear() {
try {
new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor();
}
catch (InterruptedException var1_1) {
System.out.println("InterruptedException");
}
catch (IOException var1_2) {
System.out.println("IOException");
}
System.out.println("Oxi Inventory Management [Version Alpha 0.1]");
System.out.println("(c) 2016 MidWestOxidation Enterprise. All rights reserved.");
System.out.println();
nextCommand();
}
public void newPass() {
System.out.println("This feature has not yet been implemented");
nextCommand();
}
public void popArray() {
try {
Scanner scanner = new Scanner(m);
while (scanner.hasNext()) {
tmp.add(decode(scanner.next()));
}
}
catch (FileNotFoundException var1_2) {
System.out.println("FileNotFoundException");
}
}
public void writeArray() {
m.delete();
try {
PrintWriter printWriter = new PrintWriter("mem.txt", "UTF-8");
for (int i = 0; i < tmp.size(); ++i) {
printWriter.println(encode(tmp.get(i)));
}
printWriter.close();
}
catch (FileNotFoundException var1_2) {
System.out.println("FileNotFoundException");
}
catch (UnsupportedEncodingException var1_3) {
System.out.println("UnsupportedEncodingException");
}
}
public String encode(String string) {
String string2 = "";
for (int i = 0; i < string.length(); ++i) {
string2 = string2 + shifted[indexOf(letters, string.substring(i, i + 1))];
}
return string2;
}
public String decode(String string) {
String string2 = "";
for (int i = 0; i < string.length(); ++i) {
string2 = string2 + letters[indexOf(shifted, string.substring(i, i + 1))];
}
return string2;
}
public int indexOf(String[] arrstring, String string) {
int n = -1;
for (int i = 0; i < arrstring.length; ++i) {
if (!arrstring[i].equals(string)) continue;
n = i;
break;
}
return n;
}
}