import java.util.Date; public class Article { private String title; private String content; private String author; // 新增字段:作者 private Date publishDate; // 新增字段:发布日期 public Article() { this.publishDate = new Date(); // 默认使用当前时间 } public Article(String title, String content, String author) { this.title = title; this.content = content; this.author = author; this.publishDate = new Date(); } public Article(String title, String content, String author, Date publishDate) { this.title = title; this.content = content; this.author = author; this.publishDate = publishDate; } // Getters and Setters public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } 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 + '\'' + ", content='" + content + '\'' + ", author='" + author + '\'' + ", publishDate=" + publishDate + '}'; } }