Question: package project; import java.io . FileNotFoundException; import java.io . IOException; import java.util.ArrayList; import javax.swing.JPanel; import project.enums.PostAudience; import project.enums.PostDataType; public class RegularPost extends Post { private

package project;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import javax.swing.JPanel;
import project.enums.PostAudience;
import project.enums.PostDataType;
public class RegularPost extends Post {
private ArrayList contents; // at most one image can be in a post
public RegularPost(PostAudience whoCanSee){
super(whoCanSee);
contents = new ArrayList();
}
public void addText(String text){
contents.add(new Content(text));
}
public void addImage(String fileName) throws FileNotFoundException {
contents.add(new Content(fileName, PostDataType.Image));
}
@Override
public String toString(){
/*
* regenerate this so that it is nicely formatted, especially the contents
*/
return "Post [postID="+ postID +", whoCanSee="+ whoCanSee.getDescription()+", contents="+ contents
+", popularityScore="+ popularityScore +", upVoters="+ upVoters.size()+", downVoters="
+ downVoters.size()+"]";
}
@Override
public JPanel display(){
return null;
}
}

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 Programming Questions!