diff --git a/w9 b/w9 new file mode 100644 index 0000000..64d7dc3 --- /dev/null +++ b/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 commandHistory = new ArrayList<>(); + + public void addCommand(String cmd) { + commandHistory.add(cmd); + } + + public List getCommandHistory() { + return new ArrayList<>(commandHistory); // 返回副本,防止外部修改 + } + + public void printHistory() { + for (int i = 0; i < commandHistory.size(); i++) { + System.out.println((i+1) + ": " + commandHistory.get(i)); + } + } +} \ No newline at end of file