Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

In Java, 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:John, age:37, country:US, numberOfPosts:66, numberOfLikes:123. averageLikesPerPost:1.864**

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

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago