/** * Inheritance Example * socialnetwork Example * Source code file: PhotoPost.java * This class stores information about a post * in a social network news feed. The main part of * the post consists of a photo and a caption. * Other data, such as author and time, are also * stored. * * Source: Objects First with Java * @author Michael Koelling and David J. Barnes * @version 0.3 */ public class PhotoPost extends Post { private String _filename; // the name of the image file private String _caption; // a one line image caption /** * Constructor for objects of class PhotoPost. * * @param _author The username of the author of this post. * @param _filename The filename of the image in this post. * @param _caption A caption for the image. */ public PhotoPost(String author, String filename, String caption) { super(author); this._filename = filename; this._caption = caption; } /** * Return the file name of the image in this post. * * @return The post's image file name. */ public String getImageFile( ) { return _filename; } /** * Return the caption of the image of this post. * * @return The image's caption. */ public String getCaption( ) { return _caption; } /** * Display the details of this post. * * (Currently: Print to the text terminal. * This is simulating display * in a web browser for now.) */ public void display( ) { System.out.println(" [" + _filename + "]"); System.out.println(" " + _caption); super.display( ); } }