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.
28 lines
751 B
28 lines
751 B
public class Article {
|
|
private String title;
|
|
private String url;
|
|
private String author; // 新增
|
|
private String publishDate; // 新增
|
|
|
|
// 构造器、getter/setter 相应更新
|
|
}
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class HistoryCommand {
|
|
private List<String> commandHistory = new ArrayList<>();
|
|
|
|
public void addCommand(String cmd) {
|
|
commandHistory.add(cmd);
|
|
}
|
|
|
|
public List<String> getCommandHistory() {
|
|
return new ArrayList<>(commandHistory); // 返回副本,防止外部修改
|
|
}
|
|
|
|
public void printHistory() {
|
|
for (int i = 0; i < commandHistory.size(); i++) {
|
|
System.out.println((i+1) + ": " + commandHistory.get(i));
|
|
}
|
|
}
|
|
}
|