Create a Facebook in Which Will Have Test News Feed Project Hi, please find attached of the requirement. To create a FaceBook project where it collects dif
Create a Facebook in Which Will Have Test News Feed Project Hi, please find attached of the requirement. To create a FaceBook project where it collects different posts like message post, picture post and story post and add all these posts to an array list and then display.Thanks We are going to create a FaceBook project where it collects different posts
like message post, picture post and story post and add all these posts to an
array list and then display.
For each post , there will be likes, dislikes and comments. (likes is saved in
variable and comments is saved in an array list)
Your project should have a parent class , Post , child classes MessagePost,
PicturePost and StoryPost .
It also has NewsFeed class to add the post to an arraylist and display the Posts.
It has TestNewsFeed class where you create different Post objects , pass them
to NewsFeed class to add to the Post list and display.
Your project should have the following structure. Follow the instructions
carefully to complete the project. Before you start coding, try to understand
the project structure completely.
**********************
public class Post {
private String username;
private int likes;
private long timestamp;
private ArrayList comments;
public Post(String user) {
username = user;
likes = 0;
timestamp = System.currentTimeMillis();
comments = new ArrayList();
}
public void like()
{
//add code here increment likes here
}
public void unlike()
{
//add code here to decrement likes here
}
public void addComment(String commenttext)
{
//add code here to add commenttext to comments array list
}
public long getTimeStamp()
{
return timestamp;
}
public void display() {
System.out.println(username);
System.out.println (timestring(timestamp));
System.out.println(likes + ” like this”);
//add code here to go through the comments arraylist and and print
them all
}
private String timestring(long liketime) {
long current = System.currentTimeMillis();
long diff = current-liketime;
return (diff+” “+ “secs ago”);
}
}
*************************
// here is the complete implementation of PicturePost class
public class PicturePost extends Post{
private String filename;
private String caption;
public PicturePost(String user, String file,String caption){
super(user);
filename=file;
this.caption=caption;
}
public void display() {
super.display();
System.out.println(filename);
System.out.println(caption);
}
}
*********************
// here is the partial implementation of MessagePost class
public class MessagePost extends Post {
private String message;
public MessagePost(String user,String text) {
//add code here to call super and pass user
//add code here to assign text to message
}
public void display() {
// add code to call display() of the parent
//add code to print message using system.out
}
}
******************************
//add code here to implement StoryPost class .. i leave it to your
imagination.
*****************************
public class NewsFeed {
ArrayList postList;
public NewsFeed() {
postList = new ArrayList();
}
public void addpost(Post p){
//add code here to add any Post to the arraylist postList
}
public void show() {
for (Post p : postList) {
System.out.println();
p.display();
}
}
}
*********************************
public class TestNewsFeed {
public static void main(String[] args)
{
NewsFeed nf = new NewsFeed();
//Creating MessagePost object
Post post = new MessagePost(“John”,”I cooked pasta today”);
post.like();
post.like();
post.addComment(“Awesome”);
post.addComment(“GoodJob”);
//Pass MessagePost to addpost() method to add to arraylist.
nf.addpost(post);
//Add code here to create PicturePost object , pass it to addpost()
method to add to arraylist.
//Add code here to create StoryPost object , pass it to addpost() method
to add to arraylist.
//below code shows all the posts
nf.show();
}
}
Purchase answer to see full
attachment
We've got everything to become your favourite writing service
Money back guarantee
Your money is safe. Even if we fail to satisfy your expectations, you can always request a refund and get your money back.
Confidentiality
We don’t share your private information with anyone. What happens on our website stays on our website.
Our service is legit
We provide you with a sample paper on the topic you need, and this kind of academic assistance is perfectly legitimate.
Get a plagiarism-free paper
We check every paper with our plagiarism-detection software, so you get a unique paper written for your particular purposes.
We can help with urgent tasks
Need a paper tomorrow? We can write it even while you’re sleeping. Place an order now and get your paper in 8 hours.
Pay a fair price
Our prices depend on urgency. If you want a cheap essay, place your order in advance. Our prices start from $11 per page.