So basically I have created a subclass EventPost to a given superclass Post. There is a another class called NewsFeed where I kinda run everything. But I don't really understand what is meant by "Confirm you can add instances of EventPost to the newsfeed application and display it's fields."? My guess in the main method of NewsFeed
import java.time.*;
public class EventPost extends Post{
String title;
String location;
String date;
public EventPost(String author, String title, String location, String date) {
super(author);
this.title = title;
this.location = location;
this.date = date;
}
public String getTitle(){
return title;
}
public String location(){
return location;
}
public String date(){
return date;
}
public void display(){
Post post = new post();
System.out.println("[" + title + "]");
System.out.println("location:" + location);
System.out.println("Date:" + date );
post.display();
super.display();
}
}``` ```java
import java.time.LocalDate;
import java.util.ArrayList;
import java.time.Month;
public class NewsFeed {
private ArrayList<Post> posts;
public NewsFeed() {
posts = new ArrayList<Post>();
}
public void addPost(Post post) {
posts.add(post);
}
public void show() {
// display all posts
for(Post post : posts) {
post.display();
System.out.println();
}
}
public static void main(String args[]) {
NewsFeed app = new NewsFeed();
LocalDate theDate = LocalDate.of(1989, 3, 14);
app.addPost(new EventPost("Alice", "Living the life", "Mars", theDate));
app.show();
}
}