-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathCommand.java
More file actions
41 lines (29 loc) · 756 Bytes
/
Command.java
File metadata and controls
41 lines (29 loc) · 756 Bytes
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
import java.util.Scanner;
public class Command {
CommandType type;
Command(CommandType type){
this.type=type;
}
public static Command callCommand(String s){
//Scanner in=new Scanner(System.in);
if(s.contains("Accepted")) {
return new Command(CommandType.ACCEPT);
}
if(s.contains("Rejected")) {
return new Command(CommandType.REJECT);
}
if(s.contains("Disconnect")) {
return new Command(CommandType.DISCONNECT);
}
if(s.contains("ChatApp 2015")) {
return new NickCommand(CommandType.NICK, s.replaceAll("user ", ""));
}
if(s.contains("Message")) {
return new MessageCommand(CommandType.MESSAGE,s.replaceAll("Message", ""));
}
return null;
}
public CommandType getType() {
return type;
}
}