You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.5 KiB
47 lines
1.5 KiB
import java.time.LocalDate;
|
|
|
|
public class Article {
|
|
private String title;
|
|
private String content;
|
|
private String url;
|
|
private String author;
|
|
private LocalDate publishDate;
|
|
|
|
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;
|
|
}
|
|
|
|
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; }
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "Article{" +
|
|
"title='" + title + '\'' +
|
|
", author='" + author + '\'' +
|
|
", publishDate=" + publishDate +
|
|
", url='" + url + '\'' +
|
|
'}';
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
Article article = new Article("Java编程", "内容...", "http://example.com", "张三", LocalDate.of(2024, 1, 15));
|
|
System.out.println(article);
|
|
}
|
|
}
|
|
|