Browse Source

添加 'w9'

main
Zhoutianyu 1 month ago
parent
commit
28e266fe88
  1. 28
      w9

28
w9

@ -0,0 +1,28 @@
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));
}
}
}
Loading…
Cancel
Save