From 28e266fe88aeaa48bfe8cfa9a4a460347e11d2ce Mon Sep 17 00:00:00 2001 From: Zhoutianyu <1941587995@qq.com> Date: Thu, 7 May 2026 14:30:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20'w9'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- w9 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 w9 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