Browse Source

minimum product

Lawrence Wu 6 years ago
parent
commit
3b16646eb0
1 changed files with 9 additions and 18 deletions
  1. 9
    18
      Client/src/main/java/SimpleShell.java

+ 9
- 18
Client/src/main/java/SimpleShell.java View File

76
                     continue;
76
                     continue;
77
                 }
77
                 }
78
                 if (list.get(0).equals("send")){
78
                 if (list.get(0).equals("send")){
79
-                    if (list.get(1).equals("to")){
79
+                    if (list.get(2).equals("to")){
80
                         ObjectMapper mapper = new ObjectMapper();
80
                         ObjectMapper mapper = new ObjectMapper();
81
-                        String friend = list.get(2);
81
+                        String friend = list.get(3);
82
                         String message = "";
82
                         String message = "";
83
-                        for (int i = 3; i < list.size(); i++){
83
+                        for (int i = 4; i < list.size(); i++){
84
                             message += list.get(i) + " ";
84
                             message += list.get(i) + " ";
85
                         }
85
                         }
86
-                        Message sendMessage = new Message("wulawrence", friend, message);
86
+                        String fromId = list.get(1);
87
+                        Message sendMessage = new Message(fromId, friend, message);
87
                         String messageload = mapper.writeValueAsString(sendMessage);
88
                         String messageload = mapper.writeValueAsString(sendMessage);
88
                         String results = webber.postMessage(messageload);
89
                         String results = webber.postMessage(messageload);
89
                         SimpleShell.prettyPrint(results);
90
                         SimpleShell.prettyPrint(results);
91
                     else {
92
                     else {
92
                         ObjectMapper mapper = new ObjectMapper();
93
                         ObjectMapper mapper = new ObjectMapper();
93
                         String message = "";
94
                         String message = "";
94
-                        for (int i = 1; i < list.size(); i++) {
95
+                        for (int i = 2; i < list.size(); i++) {
95
                             message += list.get(i) + " ";
96
                             message += list.get(i) + " ";
96
                         }
97
                         }
97
-                        Message messages = new Message("wulawrence", "", message);
98
+                        String fromId = list.get(1);
99
+                        Message messages = new Message(fromId, "", message);
98
                         String messageload = mapper.writeValueAsString(messages);
100
                         String messageload = mapper.writeValueAsString(messages);
99
                         String results = webber.postMessage(messageload);
101
                         String results = webber.postMessage(messageload);
100
                         SimpleShell.prettyPrint(results);
102
                         SimpleShell.prettyPrint(results);
101
                     }
103
                     }
102
                 }
104
                 }
103
-//                if (list.get(1).equals("to")){
104
-//                    ObjectMapper mapper = new ObjectMapper();
105
-//                    String friend = list.get(2);
106
-//                    String message = "";
107
-//                    for (int i = 3; i < list.size(); i++){
108
-//                        message += list.get(i) + " ";
109
-//                    }
110
-//                    Message sendMessage = new Message("wulawrence", friend, message);
111
-//                    String messageload = mapper.writeValueAsString(sendMessage);
112
-//                    String results = webber.postMessage(messageload);
113
-//                    SimpleShell.prettyPrint(results);
114
-//                }
105
+
115
                 // you need to add a bunch more.
106
                 // you need to add a bunch more.
116
 
107
 
117
                 //!! command returns the last command in history
108
                 //!! command returns the last command in history