Sfoglia il codice sorgente

add idgetter, move functionality from simpleshell

Patrick Glavin 6 anni fa
parent
commit
1861673e18

+ 22
- 1
Client/src/main/java/IDGetter.java Vedi File

@@ -1,2 +1,23 @@
1
-public class IDGetter {
1
+public class IDGetter implements Runnable{
2
+    private User user;
3
+    private YouAreEll webber;
4
+
5
+    public IDGetter(User user, YouAreEll webber) {
6
+        this.user = user;
7
+        this.webber = webber;
8
+    }
9
+
10
+    public void run() {
11
+        String results = webber.get_ids(user);
12
+        simulateLag();
13
+        SimpleShell.prettyPrintUsers(results);
14
+    }
15
+
16
+    private void simulateLag() {
17
+        try {
18
+            Thread.sleep(10000);
19
+        } catch (InterruptedException e){
20
+            e.printStackTrace();
21
+        }
22
+    }
2 23
 }

+ 3
- 2
Client/src/main/java/SimpleShell.java Vedi File

@@ -106,8 +106,9 @@ public class SimpleShell {
106 106
 
107 107
                 // ids
108 108
                 if (list.contains("ids")) {
109
-                    String results = webber.get_ids(user);
110
-                    SimpleShell.prettyPrintUsers(results);
109
+                    IDGetter idGetter = new IDGetter(user, webber);
110
+                    Thread thread = new Thread(idGetter);
111
+                    thread.start();
111 112
                     continue;
112 113
                 }
113 114