Answered step by step
Verified Expert Solution
Question
1 Approved Answer
here is the Post.java import java.util.Date; public class Post { private String comments; private String username; private String post; private Date time; private int happy;
here is the Post.java
import java.util.Date; public class Post { private String comments; private String username; private String post; private Date time; private int happy; private int sad; private int surprised; private int blank; public Post(String username, String post){ this.username = username; this.post = post; this.time = java.util.Calendar.getInstance().getTime(); this.comments = ""; } public String getComments(){ return this.comments; } public String getAuthor(){ return this.username; } public String getPost(){ return this.post; } public Date getTime(){ return this.time; } public int getHappy(){ return this.happy; } public int getSad(){ return this.sad; } public int getSurprised(){ return this.surprised; } public int getBlank(){ return this.blank; } public void react(int reaction){ if(reaction == 0) this.happy++; else if (reaction == 1) this.blank++; else if (reaction == 2) this.sad++; else if (reaction == 3) this.surprised++; } public void addComment(Comment comment){ this.comments += comment.display(); } public void display() { /*TODO*/ String s = String.format( "%s on (%s): " + "'%s' " + "=)(%d) =|(%d) =((%d) =O(%d) " + "Comments: " + "%s" , this.getAuthor(), this.getTime(), this.getPost(), this.getHappy(), this.getBlank(), this.getSad(), this.getSurprised(), this.getComments() // add the required values here ); System.out.println(s); } }
Comment.java
import java.util.Date; public class Comment { // member variables private Date time; private String author; private String content; // Getter function public Date getTime() { return this.time; } public String getAuthor() { return this.author; } public String getContent() { return this.content; } // Constructor public Comment(String author, String content) { this.content = content; this.author = author; this.time = java.util.Calendar.getInstance().getTime(); } // Function to return comments in proper format as string public String display() { /*TODO*/ String s = String.format( "->'%s' - %s (%s): " , this.getContent(), this.getAuthor(), this.getTime() // add the required values here ); return s; } }PollPost: o This subtype of Post is different in that it can be "reacted" to in two ways. This post should still be displayed with the emoji counters, but users can also submit a String answer. These will typically be a single word and can be anything! A PollPost should have a poll question and answers to the poll question as its content section. o Notice the answers contain a count next to them, and they are not sorted. You can use the StringIntPair class provided to simplify your collection of poll answers in PollPost
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started