Home / Expert Answers / Computer Science / the-class-post-is-just-a-simple-class-representing-post-a-post-contains-a-message-a-tally-of-how-m-pa786

(Solved): The class Post is just a simple class representing post. A post contains a message, a tally of how m ...



The class Post is just a simple class representing post. A post contains a message, a tally of how many people have liked it, and a number of how many times it has been reposted. It's already completed, so I don't need help with it.

I am working on a class related to the Post class and need help with the constructor and one other method. This class called User represents a user of a social media called Mastodon.

public class User {

//An ArrayList of User containing the people that this user is following

private ArrayList <User> users;

//A String containing the userName

private String userName;

// number of followers

private long NumOfFollowers;

//An ArrayList of Post containing the posts

private ArrayList <Post> posts;

//This constructor takes the user name or Id of the user. If the user name happens to be null or longer than 40 //characters or it does not happen to start with the “at”(@) annotation throw an IllegalArgumentException. Please //Initialize the other instance variables appropriately.

public User(String userName) {

}

//This method is a copy constructor which takes an existing user, a new userName, and a boolean check. This method //should create a new user with the new UserName given, and the same posts as the old user that is passed in. Don’t //copy the followers or list of users the old user is following. If the check is true make a deep copy of the old user’s post //Arraylist. If the check is false, make a shallow copy of the old user's post ArrayList, Initialize the other instance //variables appropriately.

public User(User user, String newUserName, boolean check) {

}

Java



We have an Answer from Expert

View Expert Answer

Expert Answer


Program code: import java.util.ArrayList; public class User { //An ArrayList of User containing the people that this user is following private ArrayList users; //A String containing the userName private String userName; // number of fol
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe