Browse Source

minor changes

Jennifer Chao 6 years ago
parent
commit
d4a0e428f3
2 changed files with 46 additions and 12 deletions
  1. 23
    9
      Client/src/main/java/Console.java
  2. 23
    3
      Client/src/main/java/YouAreEll.java

+ 23
- 9
Client/src/main/java/Console.java View File

4
 
4
 
5
     private static Scanner scanner = new Scanner(System.in);
5
     private static Scanner scanner = new Scanner(System.in);
6
 
6
 
7
-    public static String mainMenu() {
8
-        System.out.println("What would you like to do?" +
7
+    public static String printMainMenu() {
8
+        System.out.println("\nWhat would you like to do?" +
9
                 "\n> GET all users" +
9
                 "\n> GET all users" +
10
                 "\n> ADD your information" +
10
                 "\n> ADD your information" +
11
                 "\n> SEND a message" +
11
                 "\n> SEND a message" +
12
                 "\n> SEE all messages" +
12
                 "\n> SEE all messages" +
13
                 "\n> QUIT");
13
                 "\n> QUIT");
14
-        String option = scanner.nextLine().toUpperCase();
15
-        return option;
14
+        return scanner.nextLine().toUpperCase();
15
+    }
16
+
17
+    public static String printSendMenu() {
18
+        System.out.println("\nWhat type of message do you want to send?" +
19
+                "\n> GLOBAL message to everyone" +
20
+                "\n> DIRECT message to a specific user");
21
+        return scanner.nextLine().toUpperCase();
16
     }
22
     }
17
 
23
 
18
     public static String getName() {
24
     public static String getName() {
19
-        System.out.println("Please input your name: ");
25
+        System.out.println("\nPlease input your name: ");
20
         String name = scanner.nextLine();
26
         String name = scanner.nextLine();
21
         return name;
27
         return name;
22
     }
28
     }
23
 
29
 
24
     public static String getGithub() {
30
     public static String getGithub() {
25
-        System.out.println("Please input your Github ID: ");
31
+        System.out.println("\nPlease input your Github ID: ");
26
         String github = scanner.nextLine();
32
         String github = scanner.nextLine();
27
         return github;
33
         return github;
28
     }
34
     }
29
 
35
 
30
     public static String getFromID() {
36
     public static String getFromID() {
31
-        System.out.println("Please input your ID: ");
37
+        System.out.println("\nPlease input your ID: ");
32
         String github = scanner.nextLine();
38
         String github = scanner.nextLine();
33
         return github;
39
         return github;
34
     }
40
     }
35
 
41
 
36
     public static String getToID() {
42
     public static String getToID() {
37
-        System.out.println("Please input the receiver's ID: ");
43
+        System.out.println("\nPlease input the receiver's ID: ");
38
         String github = scanner.nextLine();
44
         String github = scanner.nextLine();
39
         return github;
45
         return github;
40
     }
46
     }
41
 
47
 
42
     public static String getMessage() {
48
     public static String getMessage() {
43
-        System.out.println("Please input your message: ");
49
+        System.out.println("\nPlease input your message: ");
44
         String github = scanner.nextLine();
50
         String github = scanner.nextLine();
45
         return github;
51
         return github;
46
     }
52
     }
53
+
54
+    public static void printError(){
55
+        System.out.println("\nAn error has occurred.");
56
+    }
57
+
58
+    public static void printSuccess(String choice) {
59
+        System.out.println("\n" + choice + " success!");
60
+    }
47
 }
61
 }

+ 23
- 3
Client/src/main/java/YouAreEll.java View File

1
+import com.fasterxml.jackson.databind.ObjectMapper;
1
 import com.mashape.unirest.http.HttpResponse;
2
 import com.mashape.unirest.http.HttpResponse;
2
 import com.mashape.unirest.http.JsonNode;
3
 import com.mashape.unirest.http.JsonNode;
3
 import com.mashape.unirest.http.Unirest;
4
 import com.mashape.unirest.http.Unirest;
18
 
19
 
19
         boolean flag = true;
20
         boolean flag = true;
20
         while (flag) {
21
         while (flag) {
21
-            String userChoice = Console.mainMenu();
22
+            String userChoice = Console.printMainMenu();
22
             switch (userChoice) {
23
             switch (userChoice) {
23
                 case "GET":
24
                 case "GET":
24
                     url.sendGetIDsRequest(url);
25
                     url.sendGetIDsRequest(url);
26
+                    Console.printSuccess(userChoice);
25
                     break;
27
                     break;
26
                 case "ADD":
28
                 case "ADD":
27
                     url.sendInputUserInfoRequest(url);
29
                     url.sendInputUserInfoRequest(url);
30
+                    Console.printSuccess(userChoice);
28
                     break;
31
                     break;
29
                 case "SEND":
32
                 case "SEND":
30
-                    url.sendGlobalMessageRequest(url);
31
-                    // url.sendDirectMessageRequest(url);
33
+                    url.sendMenu(Console.printSendMenu(), url);
34
+                    Console.printSuccess(userChoice);
32
                     break;
35
                     break;
33
                 case "SEE":
36
                 case "SEE":
34
                     url.sendGetGlobalMessagesRequest(url);
37
                     url.sendGetGlobalMessagesRequest(url);
38
+                    Console.printSuccess(userChoice);
35
                     break;
39
                     break;
36
                 case "QUIT":
40
                 case "QUIT":
37
                     flag = false;
41
                     flag = false;
38
                     break;
42
                     break;
43
+                default:
44
+                    Console.printError();
45
+                    break;
39
             }
46
             }
40
         }
47
         }
41
 //        url.sendInputUserInfoRequest(url);
48
 //        url.sendInputUserInfoRequest(url);
57
         return input;
64
         return input;
58
     }
65
     }
59
 
66
 
67
+    public void sendMenu(String sendOption, YouAreEll url) {
68
+        switch (sendOption) {
69
+            case "GLOBAL":
70
+                url.sendGlobalMessageRequest(url);
71
+                break;
72
+            case "DIRECT":
73
+                url.sendDirectMessageRequest(url);
74
+                break;
75
+            default:
76
+                break;
77
+        }
78
+    }
79
+
60
     public void inputUserInfo() throws UnirestException {
80
     public void inputUserInfo() throws UnirestException {
61
         String name = getInput(Console.getName());
81
         String name = getInput(Console.getName());
62
         String github = getInput(Console.getGithub());
82
         String github = getInput(Console.getGithub());