Skip to content
This repository was archived by the owner on Dec 1, 2020. It is now read-only.

Commit 2f2fa53

Browse files
committed
minor fixes and UX improvements
new release
1 parent e3355be commit 2f2fa53

1 file changed

Lines changed: 32 additions & 19 deletions

File tree

ProjectManager/src/Back/Main.java

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
package Back;
3-
import static java.lang.Thread.sleep;
43
import java.util.HashSet;
54
import java.util.InputMismatchException;
65
import java.util.Scanner;
@@ -50,7 +49,7 @@ public static void menutext(){
5049
}
5150

5251
public static ArrayList<Project> gettigStarted(Scanner sc, HashSet<String> hSet) {
53-
ArrayList<Project> oArrayList = new ArrayList<>();
52+
ArrayList<Project> oArrayList = new ArrayList<Project>();
5453
System.out.println("Let's start a new Project here");
5554
oArrayList.add(createProject(sc, oArrayList, hSet));
5655
return oArrayList;
@@ -90,7 +89,7 @@ public static Date scanDate( Scanner sc, String dateType ) throws ArrayIndexOutO
9089
try {
9190
String todayString = sc.nextLine();
9291
String[] todayStringArr = todayString.split("-");
93-
92+
if (todayStringArr.length > 3) return scanDate(sc, dateType);
9493
Calendar cals = parseTimestamp(todayString);
9594

9695
scDate = new Date(Integer.parseInt(todayStringArr[2]), Integer.parseInt(todayStringArr[1]),Integer.parseInt(todayStringArr[0])) ;
@@ -148,13 +147,23 @@ public static Date getToday() {
148147
return todayDate;
149148
}
150149

151-
public static void looper(ArrayList<Project> oArrayList, HashSet<String> hSet, Scanner sc, Date today){
152-
int locId = 0;
150+
public synchronized static void looper(ArrayList<Project> oArrayList, HashSet<String> hSet, Scanner sc, Date today){
151+
152+
int locId = 0;
153153
int count = 0;
154154
Date locDate = new Date();
155+
156+
155157
while(true){
156-
157-
System.out.println("\n");
158+
159+
try {
160+
Thread.sleep(500);
161+
} catch (InterruptedException e) {
162+
// TODO Auto-generated catch block
163+
e.printStackTrace();
164+
}
165+
166+
System.out.println("");
158167
menutext();
159168

160169
switch ( nlInt(sc) ) {
@@ -186,9 +195,6 @@ public static void looper(ArrayList<Project> oArrayList, HashSet<String> hSet, S
186195
System.out.println( "---------------------------------------------------------------" );
187196
for ( int i = 0; i < oArrayList.size(); i++ ){
188197
oArrayList.get(i).printProject();
189-
//the reminace of a quick and dirty solution
190-
//pro = (Project) oArrayList.get(i); //Thanks Kevin Kopp for helping out and telling me to cast because I didn't need to in the ArrayList sample+
191-
//pro.printProject();
192198
}
193199
if( oArrayList.isEmpty() ) System.out.println("no projects");
194200
System.out.println( "---------------------------------------------------------------" );
@@ -199,34 +205,41 @@ public static void looper(ArrayList<Project> oArrayList, HashSet<String> hSet, S
199205
System.out.println( "---------------------------------------------------------------" );
200206
System.out.println( "All current projects like id|name|start|end" );
201207
System.out.println( "---------------------------------------------------------------" );
202-
boolean b = false;
208+
count = 0;
203209
for (int i = 0; i < oArrayList.size(); i++ ) {
204-
b = today.isEqualEarlierDate( oArrayList.get(i).getPEndDate() ) && oArrayList.get(i).getPStartDate().isEqualEarlierDate( today ) ;
205-
if( b ) {oArrayList.get(i).printProject(); count++;}
210+
if( today.isEqualEarlierDate( oArrayList.get(i).getPEndDate() ) && oArrayList.get(i).getPStartDate().isEqualEarlierDate( today ) ) {
211+
oArrayList.get(i).printProject();
212+
count++;
213+
}
206214
}
207-
count = 0;
208215
if(count==0) System.out.println("no projects");
209216
break;
210217

211218
case 5:/**this lists all upcoming projects */
212219
System.out.println( "---------------------------------------------------------------" );
213220
System.out.println( "All upcoming projects like id|name|start|end" );
214221
System.out.println( "---------------------------------------------------------------" );
215-
for ( int i = 0; i < oArrayList.size(); i++ ) {
216-
if( today.isEarlierDate( oArrayList.get(i).getPStartDate() ) ) {oArrayList.get(i).printProject(); count++;}
217-
}
218222
count = 0;
223+
for ( int i = 0; i < oArrayList.size(); i++ ) {
224+
if( today.isEarlierDate( oArrayList.get(i).getPStartDate() ) ) {
225+
oArrayList.get(i).printProject();
226+
count++;
227+
}
228+
}
219229
if(count==0) System.out.println("no projects");
220230
break;
221231

222232
case 6:/**this lists all past projects */
223233
System.out.println("---------------------------------------------------------------");
224234
System.out.println("All past projects like id|name|start|end");
225235
System.out.println("---------------------------------------------------------------");
236+
count = 0;
226237
for (int i = 0; i < oArrayList.size(); i++) {
227-
if ( oArrayList.get(i).getPEndDate().isEqualEarlierDate( today ) ) {oArrayList.get(i).printProject(); count++;}
238+
if (oArrayList.get(i).getPEndDate().isEqualEarlierDate( today ) ) {
239+
oArrayList.get(i).printProject();
240+
count++;
241+
}
228242
}
229-
count = 0;
230243
if(count==0) System.out.println("no projects");
231244
break;
232245

0 commit comments

Comments
 (0)