-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathScenarioDriver.java
466 lines (414 loc) · 17.1 KB
/
ScenarioDriver.java
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
import javax.swing.plaf.ColorUIResource;
/**
* @author Cam Osterholt
* @version v1.0
* Date: 10/30/2023
*/
public class ScenarioDriver {
private static Scanner scnr;
//User Info: {Atticus, Madden, [email protected], password}
public static void main(String[] args) {
clearTerminal();
run();
}
/*
* Your name is Atticus Madden.
- You currently work for Code Mission Possible - A company who works on creating software solutions for clean energy.
- You are the SCRUM Manager for 3 different projects (Electric Missiles, Soap Free Washers, and Air Computers)
- Open Electric Missiles
- Add a new task "Initialize super algorithm to detonate at warp speed". Assign the task to Jeff Goldblum.
- Add a comment to the task "Avoid civilians Jeff!"
- Move the existing task of "Curve the metal to make a cylindrical shape" to the 'Doing' column. This task has the existing comments of "Not cylindrical enough" - by Jeff, and "What's a cylinder" by Atticus Finch. Reply to Jeff's comment and say "How about you do it jeff", and re-assign the task from yourself to Jeff.
- Add a new column called "Abandoned"
- Move an existing task "Make impossible burger possible" which doesn't really relate to the project purpose to "Abandoned"
- Now print the scrum board to a txt file.... make it pretty.
*/
private static void run() {
initScenario();
char choice = ' ';
while(choice != 'Z') {
scnr = new Scanner(System.in);
printActive();
System.out.print("A. User\n"
+ "B. Company\n"
+ "C. Board\n"
+ "D. Column\n"
+ "E. Task\n"
+ "Z. Quit\n"
+ "Enter selection: ");
choice = scnr.nextLine().charAt(0);
switch(choice) {
case 'A':
login();
break;
case 'B':
company();
break;
case 'C':
board();
break;
case 'D':
column();
break;
case 'E':
task();
break;
case 'Z':
AppFacade.getInstance().logOut();
return;
default:
clearTerminal();
break;
}
// System.out.println("------------------------------------\n");
}
}
private static void initScenario() {
AppFacade.getInstance().signUp("Jeff", "Goldblum", "[email protected]", "password");
AppFacade.getInstance().signUp("Atticus", "Finch", "[email protected]", "password");
AppFacade.getInstance().signUp("Atticus", "Madden", "[email protected]", "password");
CompanyManager.getInstance().addCompany(new Company("Code Mission Possible"));
AppFacade.getInstance().getActiveCompany().addBoard(new Board("Electric Missiles", false));
AppFacade.getInstance().getActiveCompany().addBoard(new Board("Soap Free Washers", false));
AppFacade.getInstance().getActiveCompany().addBoard(new Board("Air Computers", false));
System.out.println("Now opening last used Board: Electric Missiles");
AppFacade.getInstance().setActiveBoard("Electric Missiles");
Task curveMetal = new Task("Curve the metal to make a cylindrical shape");
AppFacade.getInstance().getActiveBoard().getColumn(0).addTask(curveMetal); // Create "Curve the metal to make the cylindrical shape"
Task impossibleBurger = new Task("Make impossible burger possible");
AppFacade.getInstance().getActiveBoard().getColumn(0).addTask(impossibleBurger); // Create "Curve the metal to make the cylindrical shape"
AppFacade.getInstance().login("[email protected]", "password");
curveMetal.addComment("Not cylindrical enough");
AppFacade.getInstance().login("[email protected]", "password");
curveMetal.addComment("What's a cylinder");
AppFacade.getInstance().login("[email protected]", "password");
}
private static void login() {
clearTerminal();
System.out.print("A. Login\n"
+ "B. Create New User\n"
+ "C. View User\n"
+ "D. View all Users (DEBUG)\n"
+ "Z. Exit to Menu\n"
+ "Enter selection: ");
char choice = scnr.nextLine().charAt(0);
HashMap<String, String> info = null;
switch(choice) {
case 'A':
clearTerminal();
info = getExistingData();
AppFacade.getInstance().login(info.get("Email"), info.get("Password"));
break;
case 'B':
clearTerminal();
info = getNewUserData();
AppFacade.getInstance().signUp(info.get("First Name"), info.get("Last Name"), info.get("Email"), info.get("Password"));
AppFacade.getInstance().login(info.get("Email"), info.get("Password"));
break;
case 'C':
clearTerminal();
try{
System.out.println("Active User: \n" + AppFacade.getInstance().getActiveUser().info());
}
catch (Exception e){
System.out.println("No User Logged in.");
}
break;
case 'D':
clearTerminal();
LoginManager.getInstance().printUsers();
break;
case 'Z':
clearTerminal();
return;
}
}
private static void company() {
clearTerminal();
System.out.print("A. Set Active Company\n"
+ "B. Create New Company\n"
+ "C. View Active Company\n"
+ "Z. Exit to Menu\n"
+ "Enter selection: ");
char choice = scnr.nextLine().charAt(0);
String name = null;
switch(choice) {
// Set Active Company
case 'A':
clearTerminal();
System.out.print("Enter company name: ");
name = scnr.nextLine();
if(!AppFacade.getInstance().setActiveCompany(name))
System.out.println("Company not found.");
break;
// New Company
case 'B':
clearTerminal();
System.out.print("Enter company name: ");
name = scnr.nextLine();
CompanyManager.getInstance().addCompany(new Company(name));
break;
case 'C':
clearTerminal();
try{
System.out.println("Active Company: " + AppFacade.getInstance().getActiveCompany().toString());
}
catch (Exception e){
System.out.println("No Active Company.");
}
break;
case 'Z':
clearTerminal();
return;
}
}
private static void board() {
clearTerminal();
System.out.print("A. Open Board\n"
+ "B. Create New Board\n"
+ "C. View Active Board\n"
+ "D. Create New Column\n"
+ "E. Export Board to File\n"
+ "Z. Exit to Menu\n"
+ "Enter selection: ");
char choice = scnr.nextLine().charAt(0);
String name = null;
switch(choice) {
// Open Board
case 'A':
clearTerminal();
System.out.print("Enter board name: ");
name = scnr.nextLine();
if(!AppFacade.getInstance().setActiveBoard(name))
System.out.println("Board not found.");
break;
// Create Board
case 'B':
clearTerminal();
System.out.print("Enter board name: ");
name = scnr.nextLine();
System.out.print("[O]pen or [P]rivate: ");
char openChar = scnr.nextLine().charAt(0);
boolean open = false;
if(openChar == 'O')
open = true;
AppFacade.getInstance().getActiveCompany().addBoard(new Board(name, open));
AppFacade.getInstance().setActiveBoard(name);
break;
// Active Board
case 'C':
clearTerminal();
try{
System.out.println("Active Board: " + AppFacade.getInstance().getActiveBoard().toString());
}
catch (Exception e){
System.out.println("No Active Board.");
}
break;
case 'D':
clearTerminal();
System.out.print("Enter Column Name: ");
name = scnr.nextLine();
AppFacade.getInstance().getActiveBoard().addColumn(new Column(name));
break;
case 'E':
clearTerminal();
System.out.print("Enter File Name: ");
name = scnr.nextLine();
AppFacade.getInstance().getActiveBoard().writeToTextFile(name + ".txt");
break;
case 'Z':
clearTerminal();
return;
}
}
//FIXME: Do we need??
private static void column() {
clearTerminal();
System.out.print("A. View Column\n"
+ "B. Create New Column\n"
+ "Z. Exit to Menu\n"
+ "Enter selection: ");
char choice = scnr.nextLine().charAt(0);
switch (choice) {
case 'A':
break;
case 'B':
break;
case 'C':
break;
default:
break;
}
}
private static void task() {
clearTerminal();
System.out.print("A. View Tasks\n"
+ "B. Create New Task\n"
+ "C. Comment\n"
+ "D. View Comments\n"
+ "E. Move Task\n"
+ "F. Assign Task\n"
+ "Z. Exit to Menu\n"
+ "Enter selection: ");
char choice = scnr.nextLine().charAt(0);
String name = null;
int index = 0;
String text = "";
Column col = null;
switch(choice) {
// View Tasks
case 'A':
clearTerminal();
System.out.println(AppFacade.getInstance().getActiveBoard().toString());
break;
// Create Task
case 'B':
clearTerminal();
printColumns();
index = 0;
System.out.print("Enter column choice: ");
index = Integer.parseInt(scnr.nextLine());
System.out.print("Enter Task Name: ");
text = scnr.nextLine();
AppFacade.getInstance().getActiveBoard().getColumn(index - 1).addTask(text);
break;
// Comment
case 'C':
clearTerminal();
printColumns();
index = 0;
System.out.print("Enter column choice: ");
index = Integer.parseInt(scnr.nextLine());
col = AppFacade.getInstance().getActiveBoard().getColumn(index - 1);
System.out.print("Enter Task Name: ");
text = scnr.nextLine();
Task task = col.getTask(text);
System.out.print("Enter Comment: ");
text = scnr.nextLine();
task.addComment(text);
break;
case 'D':
clearTerminal();
System.out.print("Enter Task Name: ");
name = scnr.nextLine();
commentViewer(name);
break;
case 'E':
clearTerminal();
Board ab = AppFacade.getInstance().getActiveBoard();
printColumns();
index = 0;
System.out.print("Enter original column: ");
index = Integer.parseInt(scnr.nextLine());
System.out.print("Enter Task Name: ");
name = scnr.nextLine();
System.out.print("Enter new column choice: ");
int index2 = Integer.parseInt(scnr.nextLine());
ab.moveTask(ab.getColumn(index - 1).getTitle(), ab.getColumn(index2 - 1).getTitle(), name);
System.out.println("Task is now in column: " + index2);
break;
case 'F':
clearTerminal();
System.out.print("Enter Task Name: ");
name = scnr.nextLine();
task = AppFacade.getInstance().getActiveBoard().getTask(name);
System.out.print("Enter Assignee's Email: ");
name = scnr.nextLine();
task.setAssignee(LoginManager.getInstance().getUser(name, "password"));
break;
case 'Z':
clearTerminal();
return;
}
}
private static void printColumns() {
ArrayList<Column> columns = AppFacade.getInstance().getActiveBoard().getColumns();
for(int i = 0; i < columns.size(); i++) {
System.out.println(i + 1 + ". " + columns.get(i).getTitle());
}
}
private static HashMap<String, String> getNewUserData() {
System.out.print("Enter first name: ");
String firstName = scnr.nextLine();
System.out.print("Enter last name: ");
String lastName = scnr.nextLine();
System.out.print("Enter email: ");
String email = scnr.nextLine();
System.out.print("Enter password: ");
String password = scnr.nextLine();
HashMap<String, String> ret = new HashMap<String, String>();
ret.put("First Name", firstName);
ret.put("Last Name", lastName);
ret.put("Email", email);
ret.put("Password", password);
return ret;
}
private static HashMap<String, String> getExistingData() {
System.out.print("Enter email: ");
String email = scnr.nextLine();
System.out.print("Enter password: ");
String password = scnr.nextLine();
HashMap<String, String> ret = new HashMap<String, String>();
ret.put("Email", email);
ret.put("Password", password);
return ret;
}
private static void clearTerminal() {
final String ANSI_CLS = "\u001b[2J";
final String ANSI_HOME = "\u001b[H";
System.out.print(ANSI_CLS + ANSI_HOME);
System.out.flush();
}
private static void printActive() {
try{
System.out.println("Active User: " + AppFacade.getInstance().getActiveUser().getEmail());
} catch (Exception e) {
System.out.println("Active User: NONE");
}
try{
System.out.println("Active Company: " + AppFacade.getInstance().getActiveCompany().getName());
} catch (Exception e) {
System.out.println("Active Company: NONE");
}
try{
System.out.println("Active Board: " + AppFacade.getInstance().getActiveBoard().getTitle());
} catch (Exception e) {
System.out.println("Active Board: NONE");
}
}
private static void commentViewer(String taskName) {
Task task = AppFacade.getInstance().getActiveBoard().getTask(taskName);
if(task == null) {
System.out.println("Invalid Task Name");
return;
}
ArrayList<Comment> comments = task.getComments();
char choice = ' ';
int index = 0;
if(comments.size() == 0)
System.out.println("No Commments for " + task.getName());
while(choice != 'E') {
if(index < comments.size()) {
System.out.println(comments.get(index));
System.out.print("[N]ext, [R]eply, [E]xit to Menu: ");
choice = scnr.nextLine().charAt(0);
if(choice == 'R') {
System.out.print("Enter comment: ");
String com = scnr.nextLine();
comments.get(0).reply(com);
}
if(choice == 'N')
index++;
else if(choice == 'E')
return;
clearTerminal();
}
else
return;
}
}
}