/** * Inheritance Example * socialnetwork Example * Source code file: NewsFeed.java * The NewsFeed class stores news posts for the * news feed in a social network application * (like FaceBook or Google+). * * Display of the posts is currently simulated * by printing the details to the terminal. * (In a later version, this should display in a * browser.) * * This version does not save the data to disk, * and it does not provide any search or ordering * functions. * * Source: Objects First with Java * @author Michael Koelling and David J. Barnes * @version 0.2 */ import java.util.ArrayList; public class NewsFeed { private ArrayList _posts; /** * Construct an empty news feed. */ public NewsFeed( ) { _posts = new ArrayList(); } /** * Add a post to the news feed. * * @param post The post to be added. */ public void addPost(Post post) { _posts.add(post); } /** * Show the news feed. Currently: print the news feed details * to the terminal. (To do: replace this later with display * in web browser.) */ public void show() { // display all posts for(Post post : _posts) { post.display(); System.out.println(); // empty line between posts } } }