Question: In this Assignment you will create a class that represents a Social Media profile (like a Facebook profile many of you have). The name of

In this Assignment you will create a class that represents a Social Media profile (like a Facebook profile many of you have). The name of this class will be   SocialMediaProfile  .   There are many things we could represent about a Social Media Profile, we'll pick just a few to refresh our class writing skills. A    SocialMediaProfile     will have a   name  , an   age,   a   country, a     numberOfPosts,    and    numberOfLikes.   Each of these will be private variables (these private variables must have the same exact names as the bolded names above) with the types int, double, or String (it's up to you to figure out which type for which private variable, not all types might be used). In addition to private variables you will have the following   public methods 


A constructor that will take in parameters to initialize the private variables in the order they were presented above. The constructor should ensure that anything with a number is not set to a value less than 0, if it is, then it initializes it to 0. 


Getters and setters for each private variable must follow the naming convention used in the example Student class in Lecture 1 (i.e. for age we would have   setage   and   getage  ). The setters should ensure that the private variables are never set to an illogical value (i.e. if the client passes in a negative age to setage, age remains unchanged). 


A member function, entitled   averageLikesPerPost,   that returns the average likes per post (divide numberOfLikes by number of posts). If there are no posts, simply return the value 0 (i.e. make  a condition to ensure you do not divide by 0). This takes in no parameters but it does have a return value (you must determine the return type). 


A   toString   method that overrides Object's toString, and prints out the person in the following format (the only spaces are after commas) 

name:Bob, age:27, country:US, numberOfPosts:32, numberOfLikes:155. averageLikesPerPost:2.084  


An   equals   method that overrides Object's equals. It should ensure that the Object being passed in is a SocialMediaProfile before casting it. Two Social Media Profiles are the same if all the private variables are equal. Remember to use   .equals   when comparing two Strings. You can use   ==   to compare two ints. 

Step by Step Solution

3.46 Rating (166 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To create a SocialMediaProfile class in Java that aligns with the provided requirements you need to follow these steps carefully Step 1 Class and Private Variables Define the SocialMediaProfile class ... View full answer

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!