You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
735 B
27 lines
735 B
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class HistoryCommand2 implements Command2 {
|
|
private final List<String> commandHistory = new ArrayList<>();
|
|
|
|
@Override
|
|
public String getName() {
|
|
return "history";
|
|
}
|
|
|
|
@Override
|
|
public void execute(String[] args, List<Article2> articles) {
|
|
if (commandHistory.isEmpty()) {
|
|
System.out.println("暂无历史记录");
|
|
return;
|
|
}
|
|
System.out.println("===== 命令历史 =====");
|
|
for (int i = 0; i < commandHistory.size(); i++) {
|
|
System.out.println((i+1) + ". " + commandHistory.get(i));
|
|
}
|
|
}
|
|
|
|
public void addCommand(String cmd) {
|
|
commandHistory.add(cmd);
|
|
}
|
|
}
|
|
|