-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectManagementTool.java
More file actions
4597 lines (3965 loc) · 253 KB
/
ProjectManagementTool.java
File metadata and controls
4597 lines (3965 loc) · 253 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
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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package Git.MiniProject;
import com.google.gson.Gson; //to convert from object to json
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
//import com.sun.xml.internal.bind.v2.model.core.ID;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.Map.Entry;
//the project system Main class
public class ProjectManagementTool {
// Reset
public static final String RESET = "\033[0m"; // Text Reset
// Regular Colors
public static final String RED = "\033[0;31m"; // RED
public static final String BLUE = "\033[0;34m"; // BLUE
public static final String CYAN_BRIGHT = "\033[0;96m"; // CYAN
//underline
public static final String WHITE_UNDERLINED = "\033[4;37m"; // WHITE
public static final String BLACK_BOLD = "\033[1;30m"; // BLACK
// Background
public static final String RED_BACKGROUND = "\033[41m"; // RED
public static final String WHITE_BACKGROUND = "\033[47m"; // WHITE
public static final String ANSI_RED_BACKGROUND = "\u001B[41m";
public static final String ANSI_BLUE_BACKGROUND = "\u001B[44m";
public static final String PURPLE_BACKGROUND = "\033[45m"; // PURPLE
private static final int FIRST = 0;
private static final int DATE_SUBTRACTION_CORRECTION = 1;
private static final double SALARY = 189.0;
private static final double PAY = 255.0;
//the system has projects but we work on one project.
// only for json we use the object
private ArrayList<Project> projects;
//constructor
public ProjectManagementTool(){
this.projects = new ArrayList<>();
}
//getter for the projects
public ArrayList<Project> getProjects() {
return projects;
}
//Gateway to the system
public static void main(String [] args) throws Exception {
System.out.println();
System.out.println(CYAN_BRIGHT + "This program works on Project Management Tools");
ProjectManagementTool start = new ProjectManagementTool();
start.run();
}
//Main Menu of the program
public void printMenuOption(){
System.out.println(CYAN_BRIGHT + "==============================================");
System.out.println("1. Register Project");
System.out.println("2. Register Tasks and Milestones");
System.out.println("3. Register Team Members");
System.out.println("4. Assign Dates to Tasks");
System.out.println("5. Assign Manpower to Tasks");
System.out.println("6. Register Actual Resources to Tasks");
System.out.println("7. Display All Projects");
System.out.println("8. Display Tasks and Milestones");
System.out.println("9. Display Team Members");
System.out.println("10. Display Project Schedule");
System.out.println("11. Display Resource Histogram");
System.out.println("12. Monitor Finances");
System.out.println("13. Monitor Time Spent");
System.out.println("14. Monitor Participation");
System.out.println("15. Monitor Risk");
System.out.println("16. Edit Information");
System.out.println("17. QUIT Program");
System.out.println("==============================================");
System.out.println();
}
//Second switch for option16 in menu
public void printMenuOptions(){
System.out.println("=========================================");
System.out.println("1. Edit Project Information");
System.out.println("2. Edit Task Information");
System.out.println("3. Edit Team Member Information");
System.out.println("4. Edit Allocations");
System.out.println("5. Return");
System.out.println("=========================================");
System.out.println();
}//Armin
//the gate way to the menu
public void run() throws Exception {
int optionChoice;
final int REGISTER_PROJECT = 1;
final int REGISTER_TASKS_MILESTONES = 2;
final int REGISTER_TEAM_MEMBERS = 3;
final int ASSIGN_DATES = 4;
final int ASSIGN_MANPOWER = 5;
final int REGISTER_ACTUAL_DATA = 6;
final int PRINT_ALL_PROJECTS = 7;
final int PRINT_TASKS_MILESTONES = 8;
final int PRINT_TEAM_MEMBERS = 9;
final int PRINT_PLANED_ACTUAL_SCHEDULE = 10;
final int PRINT_RESOURCE_HISTOGRAM = 11;
final int MONITOR_FINANCES = 12;
final int MONITOR_TIME_SPENT = 13;
final int MONITOR_PARTICIPATION = 14;
final int MONITOR_RISK = 15;
final int EDIT_INFO = 16;
final int QUIT = 17;
//readFromSystemClass(); //to read data by initiating a project with set values in the internal system
readFromJsonFile(); //to read data from stored json file
//checking all tasks are complete with major timeline info
projectCompletenessCheck();
//menu
do {
printMenuOption();
System.out.print("Choose menu option ");
optionChoice = new KeyboardInput().Int(); //keyboard input for the project
switch (optionChoice){
case REGISTER_PROJECT:
registerProject();
break;
case REGISTER_TASKS_MILESTONES:
registerTasksAndMilestones();
break;
case REGISTER_TEAM_MEMBERS:
registerTeamMember();
break;
case ASSIGN_DATES:
assignDates();
break;
case ASSIGN_MANPOWER:
assignManPower();
break;
case REGISTER_ACTUAL_DATA:
registerActualData();
break;
case PRINT_ALL_PROJECTS:
printProjects();
break;
case PRINT_TASKS_MILESTONES:
printTasksAndMilestones();
break;
case PRINT_TEAM_MEMBERS:
printTeamMembers();
break;
case PRINT_PLANED_ACTUAL_SCHEDULE:
printPlannedAndActualSchedule();
break;
case PRINT_RESOURCE_HISTOGRAM:
printResourceHistogram();
break;
case MONITOR_FINANCES:
monitorCosts();
break;
case MONITOR_TIME_SPENT:
monitorTimeSpent();
break;
case MONITOR_PARTICIPATION:
monitorParticipation();
break;
case MONITOR_RISK:
monitorRisk();
break;
case EDIT_INFO:
editInfo();
break;
case QUIT:
System.out.println("Saving updates. Do not turn off the computer! ");
System.out.println("***");
break;
default:
System.out.println("Option " + optionChoice + " is not valid.");
System.out.println("***");
break;
}
} while (optionChoice != QUIT);
writeProjectToJsonFile(); //Writes to project data store in Json file
}//Eyuell & Hamid
//to register projects with error handling
public void registerProject(){
System.out.println();
System.out.print("Enter name of a project ");
String projectName = new KeyboardInput().Line();
while (checkProjectName(projectName)){
System.out.print("Project Name is already used. Enter another name : ");
projectName = new KeyboardInput().Line();
}
System.out.println();
String projectID;
do {
System.out.print("Enter project ID number ");
projectID = new KeyboardInput().Line();
if (projectExists(projectID)) {
System.out.println("A project with this id already exists");
}
} while (projectExists((projectID)));
int choice;
final int SECOND_OPTION = 2;
System.out.println("How do you set the project Start and End dates :");
do{
System.out.println(" 1. Set the dates now");
System.out.println(" 2. Get the dates from the tasks ");
System.out.print("Enter option 1 or 2 ");
choice = new KeyboardInput().positiveInt();
if(choice > SECOND_OPTION){
System.out.println("Incorrect option choice ");
}
} while (choice > SECOND_OPTION);
LocalDate projectStartDate = null;
LocalDate projectFinishDate = null;
long duration = 0;
if(choice != SECOND_OPTION){ //dates now
System.out.println("Enter the Start date of the project: ");
projectStartDate = new DataEvaluator().readDate();
System.out.println("Enter the Finish date of the project: ");
projectFinishDate = new DataEvaluator().readDate();
duration = ChronoUnit.DAYS.between(projectStartDate, projectFinishDate) + DATE_SUBTRACTION_CORRECTION;
}
Project project = new Project(projectName, projectID, projectStartDate);
projects.add(project);
project.setFinishDate(projectFinishDate);
project.setDuration(duration);
System.out.println();
System.out.println("Project '" + projectName + "' is registered successfully !");
pause();
}//Eyuell & Hamid
//method to register tasks and Milestones with error handling
public void registerTasksAndMilestones(){
Project foundProject = projects.get(FIRST);
String taskID;
String milestoneID;
if(foundProject != null){
boolean continueAdding = true;
while(continueAdding){
System.out.println();
System.out.print("Enter name of a new task (Enter * to stop adding and exit) ");
String taskName = new KeyboardInput().Line();
taskName = new DataEvaluator().nameLength(taskName);
if(taskName.equals("*")){
continueAdding = false;
}
if(continueAdding){
taskID = readNewTaskID(foundProject);
int typeOfTask = typeOfTask();
Task newTask = new Task(taskName, taskID, typeOfTask);
System.out.println();
System.out.println("Task '" + taskName + "' (" + taskID + ") is registered successfully... ");
foundProject.getTasks().add(newTask);
}
}
final String YES = "Y";
//if there is a choice to register milestones now
System.out.print("Do you want to add Milestones to the project ? (Y/N) ");
String choice = new KeyboardInput().Line();
choice = new DataEvaluator().yesOrNo(choice);
if(choice.equals(YES)){
continueAdding = true;
while(continueAdding){
System.out.println();
System.out.print("Enter name of a new Milestone (Enter * to stop adding and exit) ");
String milestoneName = new KeyboardInput().Line();
milestoneName = new DataEvaluator().nameLength(milestoneName);
if(milestoneName.equals("*")){
continueAdding = false;
}
if(continueAdding){
milestoneID = readNewMilestoneID(foundProject);
System.out.println("Enter the date of the Milestone ");
LocalDate date = new DataEvaluator().readDate();
Milestone newMilestone = new Milestone(milestoneName, milestoneID, date);
System.out.println();
System.out.println("Milestone '" + milestoneName + "' (" + milestoneID + ") is registered successfully... ");
foundProject.getMilestones().add(newMilestone);
}
}
}
} else {
System.out.println("A project does not exist to add tasks on ");
}
pause();
}//Eyuell
//register team members with error handling
public void registerTeamMember(){
if(projects != null){
Project foundProject = projects.get(FIRST);
System.out.print("Enter the name of Team Member ");
String name = new KeyboardInput().Line();
while(teamMemberExists(foundProject, name)){
System.out.println("The name " + name + " is already registered ");
System.out.println();
System.out.print("Do you want to continue registering by re-writing name details ? (Y/N) ");
String choice = new KeyboardInput().Line();
choice = new DataEvaluator().yesOrNo(choice);
if(choice.equals("Y")){
System.out.print("Enter the name of Team Member ");
name = new KeyboardInput().Line();
}else{
name = ""; // to exit the loop and not add it later.
}
}
if(! name.equals("")){
System.out.print("Enter ID number for new team member " + name + " ");
String id = new KeyboardInput().Line();
while (retrieveTeamMember(foundProject, id) != null){
System.out.println("The id " + id + " is already used by other team member.");
System.out.println();
System.out.print("Enter a new ID number ");
id = new KeyboardInput().Line();
}
String qualification = readQualification();
foundProject.getTeamMembers().add(new TeamMember(name, id, qualification));
}
} else {
System.out.println("The project does not exist");
}
pause();
}//Eyuell
//assign start, finish and duration of tasks
public void assignDates(){
int STAND_ALONE = 1;
int DEPENDANT = 2;
int DURATION = 1;
int START_FINISH_DATE = 2;
if(projects != null){
Project foundProject = projects.get(FIRST);
ArrayList<Task> allTasks = foundProject.getTasks();
if (allTasks != null){
LocalDate taskStartDate;
LocalDate taskFinishDate;
long taskPlannedDuration;
int numberOfTasks = allTasks.size();
for (int i = 0 ; i < numberOfTasks; i++){
Task currentTask = allTasks.get(i);
boolean completenessCheck = completenessCheck(currentTask);
if(! completenessCheck){ //if not complete
int taskType = currentTask.getTypeOfTask();
System.out.println();
System.out.println("Data for task '" + currentTask.getName() + "' : ");
if(taskType == STAND_ALONE){ //stand alone
System.out.println("Enter the start date of the task ");
taskStartDate = new DataEvaluator().readDate();
currentTask.setPlannedStart(taskStartDate);
int lengthOfTask = readLengthOfTask();
if(lengthOfTask == DURATION){
System.out.print("Enter the planned duration of the task ");
taskPlannedDuration = new KeyboardInput().positiveInt();
currentTask.setPlannedDuration(taskPlannedDuration);
LocalDate finishDate = currentTask.getPlannedStart().plusDays(taskPlannedDuration);
currentTask.setPlannedFinish(finishDate);
}else if(lengthOfTask == START_FINISH_DATE){
System.out.println("Enter the finish date of the task ");
taskFinishDate = new DataEvaluator().readDate();
currentTask.setPlannedFinish(taskFinishDate);
long duration = ChronoUnit.DAYS.between(currentTask.getPlannedStart(), taskFinishDate) + DATE_SUBTRACTION_CORRECTION;
currentTask.setPlannedDuration(duration);
}
} else if (taskType == DEPENDANT){ //dependant on other task
String connectivityType;
long connectivityDuration;
boolean repeat;
do{
repeat = false;
Task foundTask;
int ONE = 1;
System.out.println("How many connectivity does this task has with other tasks ?");
int numberOfConnectivity = new KeyboardInput().positiveInt();
if (numberOfConnectivity >= ONE){
for(int j = ONE; j <= numberOfConnectivity; j++){ // if there is connectivity, it should start from one
System.out.println("Connectivity " + ( j ) + ": ");
System.out.println("On which task does the current task depend on ? ");
String toBeConnectedToTaskID = readExistingTaskID(foundProject);
foundTask = retrieveTask(toBeConnectedToTaskID, foundProject);
connectivityType = readConnectivityType();
System.out.print("Enter the duration of connectivity. (It could be negative if applicable) ");
connectivityDuration = new KeyboardInput().Int();
currentTask.getConnectivity().add(new Connectivity(foundTask, connectivityType, connectivityDuration));
}
}
LocalDate startDate = new DataEvaluator().extractConnectivityDate("start",currentTask.getConnectivity() );
LocalDate finishDate = new DataEvaluator().extractConnectivityDate("finish",currentTask.getConnectivity() );
if(startDate != null && finishDate != null){
if(finishDate.isAfter(startDate)){
long duration = ChronoUnit.DAYS.between(startDate, finishDate) + DATE_SUBTRACTION_CORRECTION;
currentTask.setPlannedStart(startDate);
currentTask.setPlannedFinish(finishDate);
currentTask.setPlannedDuration(duration);
repeat = false;
}else {
System.out.println("There is an error on connectivity that results an end date before a start date. Correct the data again");
repeat = true;
}
}else {
int lengthOfTask = readLengthOfTask();
if(lengthOfTask == DURATION){
System.out.print("Enter the planned duration of the task : " + currentTask.getName() + " ");
taskPlannedDuration = new KeyboardInput().positiveInt();
currentTask.setPlannedDuration(taskPlannedDuration);
if(startDate != null){
finishDate = startDate.plusDays(taskPlannedDuration);
currentTask.setPlannedFinish(finishDate);
} else {
startDate = finishDate.minusDays(taskPlannedDuration);
currentTask.setPlannedStart(startDate);
}
} else if(lengthOfTask == START_FINISH_DATE){
if(startDate != null){
System.out.println("Enter the Finish date of the task : " + currentTask.getName() + " ");
LocalDate fDate = new DataEvaluator().readDate();
while (fDate.isBefore(startDate)){
System.out.println("Finish date of the task should not be before a Start date. ");
System.out.print("Enter the finish date correctly ");
fDate = new DataEvaluator().readDate();
}
currentTask.setPlannedFinish(fDate);
currentTask.setPlannedStart(startDate);
long duration = ChronoUnit.DAYS.between(startDate, fDate) + DATE_SUBTRACTION_CORRECTION;
currentTask.setPlannedDuration(duration);
} else {
System.out.println("Enter the Start date of the task : " + currentTask.getName() + " ");
LocalDate sDate = new DataEvaluator().readDate();
while (sDate.isAfter(finishDate)){
System.out.println("Start date of the task should not be after a Finish date. ");
System.out.print("Enter the Start date correctly ");
sDate = new DataEvaluator().readDate();
}
currentTask.setPlannedStart(sDate);
currentTask.setPlannedFinish(finishDate);
long duration = ChronoUnit.DAYS.between(sDate, finishDate) + DATE_SUBTRACTION_CORRECTION;
currentTask.setPlannedDuration(duration);
}
}
}
}while (repeat);
}
//completeness once again
completenessCheck(currentTask);
}
}
checkWithProjectTimes(foundProject);
System.out.println("All tasks planned times are complete ");
System.out.println();
checkActualFinishDates(allTasks);
}else {
System.out.println("There are no tasks in the project yet ");
}
} else {
System.out.println("The project does not exist");
}
pause();
}//Eyuell
public void assignManPower(){
if (projects != null){
Project foundProject = projects.get(FIRST);
if(foundProject.getTasks() != null){
int numberOfTasks = foundProject.getTasks().size();
for(int i = 0; i < numberOfTasks; i++){
System.out.println();
Task task = foundProject.getTasks().get(i);
LocalDate startDate = task.getPlannedStart();
long days = task.getPlannedDuration();
for(int j = 0; j < days; j++){
boolean repeat;
LocalDate date = startDate.plusDays((long) j); //date
do{
repeat = true;
System.out.println("Enter Man hour need for Task ID (" + task.getId() + ") on date " + date + ": ");
System.out.print(" Enter * to escape to another day ");
String timeInput = new KeyboardInput().Line();
if(timeInput.equals("*")){
completenessCheck(task); // this may not be needed
repeat = false;
}else{
double time = new DataEvaluator().positiveDouble(timeInput); //time
String qualification = readQualification(); //qualification
Manpower manPower = new Manpower(qualification);
task.getPlannedManpower().add(new ManpowerAllocation(manPower,time,date));
}
}while (repeat);
}
}
System.out.println();
System.out.println("Manpower allocated successfully...");
}else{
System.out.println("There are no tasks in the project");
}
}else {
System.out.println("There are no projects to show");
}
pause();
}//Eyuell
public void registerActualData(){
LocalDate today = LocalDate.now();
if (projects != null ){
Project foundProject = projects.get(FIRST);
if(foundProject.getTasks() != null){
String taskId = readExistingTaskID(foundProject);
Task foundTask = retrieveTask(taskId,foundProject);
if(foundTask.getActualStart() == null){ //if no start date
System.out.println("Actual start date of the task " + taskId + " needs to be provided first. ");
LocalDate startDate = new DataEvaluator().readDate();
while(startDate.isAfter(today)){
System.out.print("An actual start date cannot be after today. Enter a correct date ");
startDate = new DataEvaluator().readDate();
}
foundTask.setActualStart(startDate);
}
LocalDate possibleFinalDate = today;
if(foundTask.getActualStart() != null){
if(foundTask.getActualFinish() == null){ //if no finish
boolean taskStatus = readActualTaskStatus();
foundTask.setStatusOfTask(taskStatus);
if(taskStatus){
System.out.println("Enter the actual finish date of the task ");
boolean beforeStart;
do{
possibleFinalDate = new DataEvaluator().readDate();
beforeStart = possibleFinalDate.isBefore(foundTask.getActualStart());
if(beforeStart){
System.out.print("Actual finish date cannot be before actual start date. Enter the correct finish date ");
}
}while (beforeStart);
}
foundTask.setActualFinish(possibleFinalDate);
//
}else if(foundTask.getActualFinish().equals(today)){ // if the task is active
System.out.print("Do you want to update the actual finish date ? (Y/N) ");
String choice = new KeyboardInput().Line();
choice = new DataEvaluator().yesOrNo(choice);
if(choice.equals("Y")){ //TBD: here may be i need to check if already entered resources data is not out of final day
System.out.println("Enter the actual finish date ");
boolean beforeStart;
LocalDate finish;
do{
finish = new DataEvaluator().readDate();
beforeStart = finish.isBefore(foundTask.getActualStart());
if(beforeStart){
System.out.print("Actual finish date cannot be before actual start date. Enter the correct finish date ");
}
}while (beforeStart);
foundTask.setActualFinish(finish);
foundTask.setStatusOfTask(true);
}
}
System.out.print("Do you want to register actual data for this task ? (Y/N) ");
String yesOrNo = new KeyboardInput().Line();
yesOrNo = new DataEvaluator().yesOrNo(yesOrNo);
if(yesOrNo.equals("Y")){
System.out.println("On which day do you want to register data ? ");
LocalDate editDate = new DataEvaluator().readDate();
while(editDate.isAfter(foundTask.getActualFinish()) || editDate.isBefore(foundTask.getActualStart())){
System.out.print("Date should be between Actual Start date ");
if(foundTask.getActualFinish() != null){
System.out.print("and finish date.");
}else{
System.out.println("and today.");
}
System.out.print(" Enter a correct date ");
editDate = new DataEvaluator().readDate(); //date
}
System.out.println("Which team member has participated on the task ? ");
TeamMember foundMember;
do{
System.out.print("Enter id ");
String id = new KeyboardInput().Line();
foundMember = retrieveTeamMember(foundProject, id);
if(foundMember == null){
System.out.println("Team member not found. Try again ");
}
}while (foundMember == null);
System.out.print("How long time is to be registered in decimal form ");
double hoursWorked = new KeyboardInput().positiveDouble(); //hours
foundTask.getActualTeamMembers().add(new TeamMemberAllocation(foundMember,hoursWorked,editDate));
updateDates(foundTask, foundTask.getPlannedStart(),foundTask.getPlannedFinish(),foundTask.getActualStart(),foundTask.getActualFinish());
}
}
//
}else{
System.out.println("There are no tasks in the project ");
}
}else{
System.out.println("There are no projects to show ");
}
pause();
}//Eyuell
//Print tasks or milestones
public void printTasksAndMilestones() {
int option;
boolean input;
do {
System.out.println("What do you wish to print?");
System.out.println("1. Tasks ");
System.out.println("2. Milestones");
System.out.println("3. Return");
option = new KeyboardInput().Int();
if (option == 1) {
printTasks();
input = false;
} else if (option == 2) {
printMileStones();
input = false;
} else if (option == 3) {
//Return
System.out.println();
input = false;
} else {
System.out.println("option must be 1-3. ");
input = true;
}
}while (input);
}//Armin
//print only tasks
public void printTasks(){
int option;
boolean input;
do {
System.out.println("What do you wish to print?");
System.out.println("1. All Tasks ");
System.out.println("2. Specific Task");
System.out.println("3. Return");
option = new KeyboardInput().Int();
if (option == 1) {
printAllTasksAndMilestones();
input = false;
} else if (option == 2) {
printSpecificTaskMilestones();
input = false;
} else if (option == 3) {
//Return
System.out.println();
input = false;
} else {
System.out.println("option must be 1-3. ");
input = true;
}
}while (input);
}//Armin
public void printAllTasksAndMilestones(){
Project currentProject = projects.get(FIRST);
ArrayList<Task> tasks = currentProject.getTasks();
String option;
boolean error;
if(tasks != null) {
for (int i = 0; i < tasks.size(); i++) {
System.out.println("Name of task: " + tasks.get(i).getName());
System.out.println("Planned start date: " + tasks.get(i).getPlannedStart());
System.out.println("Planned finish date: " + tasks.get(i).getPlannedFinish());
System.out.println("Actual date of start: " + tasks.get(i).getActualStart());
System.out.println("Actual End date: " + tasks.get(i).getActualFinish());
System.out.println("Planned duration of task is " + tasks.get(i).getPlannedDuration() + " days.");
System.out.println("------------------------------------------------------------");
}
do {
System.out.println("------------------------------------------------------------");
System.out.println("Do you wish to print milestones?");
System.out.println("1. Yes");
System.out.println("2. No");
option = new KeyboardInput().Line();
System.out.println("------------------------------------------------------------");
if (option.equalsIgnoreCase("1") || option.equalsIgnoreCase("yes")) {
printMileStones();
error = false;
} else if (option.equalsIgnoreCase("2") || option.equalsIgnoreCase("no")) {
System.out.println("Milestones not printed.");
error = false;
pause();
} else {
System.out.println("Options are 1 or 2");
System.out.println("----------------------------------------------------------------");
error = true;
}
} while (error);
}
}//Armin
public void printSpecificTaskMilestones() {
Project currentProject = projects.get(FIRST);
if (currentProject.getTasks() != null) {
listTasks();
String taskID;
boolean error;
String option;
do {
try {
System.out.println("Enter the id of a task");
taskID = new KeyboardInput().Line();
System.out.println("------------------------------------------------------------");
Task foundTask = retrieveTask(taskID, currentProject);
System.out.println("Name of task: " + foundTask.getName());
System.out.println("Planned start date: " + foundTask.getPlannedStart());
System.out.println("Planned finish date: " + foundTask.getPlannedFinish());
System.out.println("Actual date of start: " + foundTask.getActualStart());
System.out.println("Actual Enddate: " + foundTask.getActualFinish());
System.out.println("Planned duration of task is "+foundTask.getPlannedDuration()+" days.");
error = false;
} catch (Exception e) {
System.out.println("Input integer, or wrong taskID was inputted.");
System.out.println("------------------------------------------------------------");
error = true;
}
do {
System.out.println("------------------------------------------------------------");
System.out.println("Do you wish to print milestones?");
System.out.println("1. Yes");
System.out.println("2. No");
option = new KeyboardInput().Line();
System.out.println("------------------------------------------------------------");
if (option.equalsIgnoreCase("1")||option.equalsIgnoreCase("yes")) {
printMileStones();
error = false;
} else if (option.equalsIgnoreCase("2")||option.equalsIgnoreCase("no")) {
System.out.println("Milestones not printed.");
error = false;
}else{
System.out.println("Options are 1 or 2");
System.out.println("----------------------------------------------------------------");
error=true;
}
}while (error);
} while (error);
}else {
System.out.println("There are no Tasks registered");
System.out.println();
}
}//Armin
public void printMileStones() {
int option;
boolean input;
do {
System.out.println("Do you wish to print: ");
System.out.println("1. All Milestones");
System.out.println("2. Specific Milestone");
System.out.println("3. Return");
option = new KeyboardInput().Int();
if (option == 1){
printAllMilestones();
input = false;
} else if(option == 2){
printSpecificMileStones();
input = false;
} else {
System.out.println("Options are 1, 2 or 3.");
System.out.println("----------------------------------------------------------------");
input = true;
}
}while (input) ;
}//Armin
public void printSpecificMileStones() {
Project currentProject = projects.get(FIRST);
listMilestones();
if (currentProject.getMilestones() != null) {
boolean error;
String milestoneID;
do {
try {
System.out.println("Enter the id of a Milestone you wish to print");
milestoneID = new KeyboardInput().Line();
System.out.println("----------------------------------------------------------------");
Milestone foundMilestone = retrieveMilestone(currentProject, milestoneID);
System.out.println("Name: " + foundMilestone.getName());
System.out.println("Date: " + foundMilestone.getDate());
System.out.println("----------------------------------------------------------------");
error = false;
}catch (Exception e){
System.out.println("Input integer.");
System.out.println("----------------------------------------------------------------");
error = true;
}
}while (error);
}else {
System.out.println("There are no Milestones registered");
System.out.println();
}
pause();
}//Armin
public void printAllMilestones() {
Project currentProject = projects.get(FIRST);
ArrayList<Milestone> milestones = currentProject.getMilestones();
if (milestones != null) {
for (int i = 0; i < milestones.size(); i++) {
System.out.println("Name: "+milestones.get(i).getName());
System.out.println("Date: "+milestones.get(i).getDate());
System.out.println("----------------------------------------------------------------");
}
}else {
System.out.println("There are no Milestones registered");
System.out.println();
}
pause();
}//Armin
public void printProjects() {
int option;
boolean input;
do {
System.out.println("Do you wish to print: ");
System.out.println("1. All projects");
System.out.println("2. Specific Project");
System.out.println("3. Return");
option = new KeyboardInput().Int();
if (option == 1) {
printAllProjects();
input = false;
} else if (option == 2) {
printSpecificProject();
input = false;
}else if (option==3){
System.out.println();
input = false;
} else {
System.out.println("Options are 1, 2 or 3.");
System.out.println("----------------------------------------------------------------");
input = true;
}
}while (input) ;
}//Armin
public void printAllProjects() {
if(projects != null){
System.out.println("Here is a List of all Current projects: ");
System.out.println("----------------------------------------------------------------");
for (int i = 0; i < projects.size(); i++) {
System.out.println("Project ID Assigned: "+projects.get(i).getProjectID());
System.out.println("Project name: "+projects.get(i).getName());
System.out.println("Project Start date: "+projects.get(i).getStartDate());
System.out.println("Project End date: "+projects.get(i).getFinishDate());
System.out.println("----------------------------------------------------------------");
}}
else {
System.out.println("There are no projects registered");
System.out.println();
}
}//Armin
public void printSpecificProject(){
String projectId="";
boolean error= true;
do {
try {
System.out.println("Enter project id");
projectId = new MiniProject.KeyboardInput().Line();
if (!projectExists(projectId)) {
System.out.println("This project id does not exist");
}