1 changed files with 28 additions and 0 deletions
@ -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…
Reference in new issue