Question: 1- Likeable Implement the interface Likeable. It declares two methods: like() and int getLikes() . 2- Post Write the implementation of the class Post. It

1- Likeable

Implement the interface Likeable. It declares two methods: like() and int getLikes().

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() to obtain a Date object representing the current time. A Dateobject has a method toString() that converts this date to a String
    Date rightNow = Calendar.getInstance().getTime(); System.out.println(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 implementation.

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.1- Likeable Implement the interface Likeable. It declares two methods: like() and

Just need the answer to PhotoPost! Thank you!

PhotoPost.java TextPost.java 1 public class PhotoPost extends Post t private String fileName; private String caption; 4 public PhotoPost (String userName, String fileName, String caption) f /Your code here. 9 10 public String getCaption) return caption; 12 13 14 15 16 17 18 19 20 21 public String getFileName) return fileName; public String toString) String str -new String); str super.toString) ", " fileName +", "caption; return str; 23 24 25

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!