-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommand.java
More file actions
48 lines (38 loc) · 938 Bytes
/
Command.java
File metadata and controls
48 lines (38 loc) · 938 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
42
43
44
45
46
47
48
package myclasses;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import enums.CommandWord;
/*
* @author Brian Mukeswe
* @contact b.mukeswe@sms.ed.ac.uk
*
*/
public class Command {
private CommandWord command;
private List<String> parameters = new ArrayList<>();
public Command(CommandWord command) {
this.command = command;
}
// Give parameters to the command
public void setParameters(Iterator<String> parameters) {
if (parameters != null) {
if (parameters.hasNext() == true) {
this.parameters.add(parameters.next());
}
}
}
// Retrieve the parameters of the command
public Iterator<String> getParameters(){
if (parameters.isEmpty() == false) {
return parameters.iterator();
}
else {
return null;
}
}
// Retrieve the name of the command
public CommandWord getCommandWord() {
return command;
}
}