Question: 2- Post Write the implementation of the class Post. It implements the characteristics that are common to its sub-classes, here TextPost and PhotoPost. Post implements








2- Post Write the implementation of the class Post. It implements the characteristics that are common to its sub-classes, here TextPost and PhotoPost. Post implements the interface Likeable. All the Post messages have a user name, a time stamp (of type java.util.Date), as well as a count for the number of likes. .The value of the time stamp is automatically assigned when an object is created. Use java.util.Calendar.getInstance).getTime(0 to obtain a Date object representing the current time. A Date object has a method toString0 that converts this date to a String Date rightNow Calendar.getInstan) getTime); Sys) stem.out.printin(rightNow Each call to the method like) increases the number of likes for this message. .Post implements the interface Comparable. This interface allows you to compare two Post according to specific criteria. In this case the criteria will be the date of the post.For more information, refer to the documentation. .Add the method isPopular. This method returns true if the post is considered popular (more the 100 likes), false otherwise. .Do not forget the method toString)! 3- PhotoPost Implement the class PhotoPost. A PhotoPost is a specialized Post. It stores a file name and a caption. Override the method toString() by using the keyword "super" in your mnlemPntatinn 428 AM Type here to search ^-,40 2/8/2019 4- TextPost Implement the class TextPost. A TextPost is a specialized Post. It stores a text message (String). Override the method toString using the keyword "super" in your implementation. A TextPost is considered popular if the post gets more than 50 likes. 5- NewsFeed Write the implementation of the class NewsFeed. A NewsFeed object stores Post messages .It uses a fixed size array of some constant size MAX SIZE to store Post messages. For this implementation will only accept up to 25 Post messages. .It has a method for adding a Post message. The message is added after the last message added. . It has a method sort in which the Post are sorted from the oldest to the most recent. . It has a method for returning the message found at a given index, Post get(int index). .It has a method size that returns the number of messages currently stored. . It has a method getPhotoPost that returns a new object of type NewsFeed containing only the PhotoPost .It has an instance method plus that has one formal parameter of type NewsFeed. This method returns a new object of type NewsFeed that represents the combination of the two NewsFeed. The Post of the new NewsFeed have to be sorted from the oldest to the most recent one. Bonus 4:98 AM Type here to search 40 2/8/2019 ^ ktop Likeablejava -Sublime Text (UNREGISTERED) pTextPost.java Sublime Text (UNREGISTERED) ile Edit Selection Find View Goto Tools Project Preferences Help File Edit Selection Find View Goto Tools Project Preferences Help 1 public interface Likeable f 1 public class TextPost extends Post f public abstract void like(); public abstract int getLikes private String message; public TextPost (String userName, String message) ( // Your code here Line 5, Column 1 PhotoPost.java 1 public class PhotoPost extends Post ( Tab Size: 4 public String getlessage) 10 return message; 12 13 14 15 16 17 18 19 20 21 private String fileName; private String caption; public String tostring)t 4 String str new String); str super.toString) ", " message; return str; public PhotoPost (String userName, String fileName, Stri //-Your-code-here 8 public boolean isPopular()( public String getCaption() return caption; 10 // Your code here 12 13 public String getFileName() f 23 24 return fileName; 16 17 18 19 public String toString) String str -new String); str super.toString() "fileName ", "+ c return str; 21 23 Line 11, Column Spaces: 2 4:30 AM Type here to search 2/8/2019 NewsFeed.java Sublime Text (UNREGISTERED) File Edit Selection Find View Goto Tools Project Preferences Help Newsfeed.java 2 Use static array for NewsFeed 3 with constant MAX SIZE 6 public class NewsFeed private Post[] messages; private int size public static final int MAX SIZE 25; 10 public NewsFeed) 12 13 14. 15 16 17 18 19 20 21 // Your code here public void add (Post message) // Your code here public Post get(int index) f return messages [index]; 23 24 25 26 27 28 29 30 31 32 public int size() return size; public void sort)( int i, j, argMin; Post tmp; for (i -e; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
