diff --git a/article类 b/article类 new file mode 100644 index 0000000..912f4dc --- /dev/null +++ b/article类 @@ -0,0 +1,67 @@ +import java.time.LocalDate; + +public class Article { + private String title; + private String content; + private String url; + + // 作业要求新增 + private String author; + private LocalDate publishDate; + + public Article() { + } + + public Article(String title, String content, String url, String author, LocalDate publishDate) { + this.title = title; + this.content = content; + this.url = url; + this.author = author; + this.publishDate = publishDate; + } + + // getter & setter + 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 getUrl() { + return url; + } + public void setUrl(String url) { + this.url = url; + } + + public String getAuthor() { + return author; + } + public void setAuthor(String author) { + this.author = author; + } + + public LocalDate getPublishDate() { + return publishDate; + } + public void setPublishDate(LocalDate publishDate) { + this.publishDate = publishDate; + } + + // 打印文章信息 + public void showInfo() { + System.out.println("标题:" + title); + System.out.println("作者:" + author); + System.out.println("发布日期:" + publishDate); + System.out.println("链接:" + url); + System.out.println("内容:" + content); + } +} \ No newline at end of file