From 911d0fba4c9bc39638c08fc06097e1315e3d1e53 Mon Sep 17 00:00:00 2001 From: ZhangJinxuan <2194936226@qq.com> Date: Mon, 25 May 2026 14:52:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0w10=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Article.java | 59 ++++++++++++++++++++++++++++++++++++++++++++ HistoryCommmand.java | 17 +++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 Article.java create mode 100644 HistoryCommmand.java diff --git a/Article.java b/Article.java new file mode 100644 index 0000000..358503f --- /dev/null +++ b/Article.java @@ -0,0 +1,59 @@ +package com.example.datacollect.model; +import java.util.Date +public class Article { + private String title; + private String url; + private String content; + private String author; + private Date publishDate; + public Article(String title, String url, String content,String author,Date publishDate) { + this.title = title; + this.url = url; + this.content = content; + this.author = author; + this.publishDate= publishDate; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + public String getAuthor(){ + return author; + } + public void setAuthor(String author){ + this.author= author; + } + public Date getPublishDate() { + return publishDate; + } + public void setPublishDate(Date publishDate) { + this.publishDate = publishDate; + } + @Override + public String toString() { + return "Article{" + + "title='" + title + '\'' + + ", url='" + url + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/HistoryCommmand.java b/HistoryCommmand.java new file mode 100644 index 0000000..7310ed5 --- /dev/null +++ b/HistoryCommmand.java @@ -0,0 +1,17 @@ +import java.util.ArrayList; +import java.util.List; + +public class HistoryCommand { + // 存储所有输入过的命令 + private final List commandHistory = new ArrayList<>(); + + // 添加命令 + public void addCommand(String cmd) { + commandHistory.add(cmd); + } + + // 获取全部历史 + public List getHistory() { + return new ArrayList<>(commandHistory); // 防御性拷贝,避免外部修改 + } +} \ No newline at end of file