Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

***FILL IN THE PROVIDED CODE, WITH ONLY FILE 5-7 NEEDING TO BE FILLED *** Object

ID: 3718960 • Letter: #

Question

***FILL IN THE PROVIDED CODE, WITH ONLY FILE 5-7 NEEDING TO BE FILLED ***

Objective: The popular social network Facebook™ was founded by Mark Zuckerberg and his classmates at Harvard University in 2004. At the time, he was a sophomore studying computer science. Design and implement an application that maintains the data for a simple social network. Each person in the network should have a profile that contains the person’s name, an optional image, current status, and a list of friends. Your application should allow a user to join the network, leave the network, create a profile, modify the profile, search for other profiles, and add friends. The code and the output for this part are in the ZIP archive. Your program’s output must be identical to the output of the sample run, “_OUTPUT.txt”.

File 1: _OUTPUT.txt

run:

Creating profiles and adding to database.

Name: John Doe

Status: My name is John.

Picture: BufferedImage@52e922

# of friends: 0

Friends:

Name: Jane Doe

Status: My name is Jane.

Picture: BufferedImage@25154f

# of friends: 0

Friends:

Name: Billy Bob

Status: My name is Billy Bob!

Picture: BufferedImage@10dea4

# of friends: 0

Friends:

Name: John Smith

Status: My name is also John.

Picture: BufferedImage@647e05

# of friends: 0

Friends:

-------------------------------------

Creating friendships.

Name: John Doe

Status: My name is John.

Picture: BufferedImage@52e922

# of friends: 2

Friends:

Jane Doe

John Smith

Name: Jane Doe

Status: My name is Jane.

Picture: BufferedImage@25154f

# of friends: 3

Friends:

John Doe

Billy Bob

John Smith

Name: Billy Bob

Status: My name is Billy Bob!

Picture: BufferedImage@10dea4

# of friends: 2

Friends:

Jane Doe

John Smith

Name: John Smith

Status: My name is also John.

Picture: BufferedImage@647e05

# of friends: 3

Friends:

John Doe

Jane Doe

Billy Bob

-------------------------------------

Changing statuses / names.

Name: John Doe

Status: My name is John.

Picture: BufferedImage@52e922

# of friends: 2

Friends:

Jane Smith

John Smith

Name: Jane Smith

Status: Now Mrs. Smith!

Picture: BufferedImage@25154f

# of friends: 3

Friends:

John Doe

Billy Bob

John Smith

Name: Billy Bob

Status: My name is Billy Bob!

Picture: BufferedImage@10dea4

# of friends: 2

Friends:

Jane Smith

John Smith

Name: John Smith

Status: Just got married!

Picture: BufferedImage@647e05

# of friends: 3

Friends:

John Doe

Jane Smith

Billy Bob

-------------------------------------

Ending a friendship.

Name: John Doe

Status: My name is John.

Picture: BufferedImage@52e922

# of friends: 2

Friends:

Jane Smith

John Smith

Name: Jane Smith

Status: Now Mrs. Smith!

Picture: BufferedImage@25154f

# of friends: 3

Friends:

John Doe

Billy Bob

John Smith

Name: Billy Bob

Status: My name is Billy Bob!

Picture: BufferedImage@10dea4

# of friends: 2

Friends:

Jane Smith

John Smith

Name: John Smith

Status: Just got married!

Picture: BufferedImage@647e05

# of friends: 3

Friends:

John Doe

Jane Smith

Billy Bob

-------------------------------------

Removing John.

Name: Jane Smith

Status: Now Mrs. Smith!

Picture: BufferedImage@25154f

# of friends: 2

Friends:

Billy Bob

John Smith

Name: Billy Bob

Status: My name is Billy Bob!

Picture: BufferedImage@10dea4

# of friends: 2

Friends:

Jane Smith

John Smith

Name: John Smith

Status: Just got married!

Picture: BufferedImage@647e05

# of friends: 2

Friends:

Jane Smith

Billy Bob

BUILD SUCCESSFUL (total time: 0 seconds)

File 2: AList

File 3: Driver

File 4: ListInterface

File 5: Name

File 6: Profile

File 7: ProfileManager

Explanation / Answer

Following tis the commented code for files 5,6 and 7. Have added some suggestions in the add.

File 5:Name

public class Name

{

  

private String first; // First name

private String last; // Last name

  

public Name () //Empty condtructor

{

  

}

  

public Name (String firstName, String lastName) //Construtor to set the name

{

first = firstName;

last = lastName;

}

  

public void setName (String firstName, String lastName) //Method to set name or to change name

{

first = firstName;

last = lastName;

}

public String getName () //returns both first and last name in form of a string

{

String name;

name = first + " " + last;

return name;

  

}

public void setFirst (String firstName) //Sets or changes only the first name

{

first = firstName;

  

}

public String getFirst () //Returns only the first name

{

return first;

  

}

public void setLast (String lastName) //Sets only the last name;

{

last = lastName;

  

}

public String getLast () //returns only the last name

{

returns last;

  

}

public void giveLastNameTo (Name aName) //Not sure about this method. Am assuming it sets

{ // the last name of the current name to aName

  

aName.setLast(last);

}

public String toString () //Returns all the useful information of the class in a string

{

String ans;

ans = "Name: " + first + " " + last;

}

}

File 6:Profile

import java.awt.image.*;

/**

* A profile on a simple social network.

*/

public class Profile

{

  

private BufferedImage profilePicture;

  

private Name profileName;

  

private String status;

  

private AList < Profile > friends;

  

/**

* DO NOT CHANGE

* Constructor for an instance of a profile.

*/

public Profile ()

{

  

/**

* DO NOT CHANGE

* Constructor for an instance of a profile.

*/

profilePicture =

new BufferedImage (150, 150, BufferedImage.TYPE_INT_RGB);

  

profileName = new Name ("", "");

  

status = "";

  

friends = new AList <> ();

  

}

public BufferedImage getProfilePicture () //This would return data type bufferedpicture

{

return profilePicture;

  

}

public void setProfilePicture (BufferedImage newPicture) //Would set or change the profile pic

{

profilePicture = newPicture;  

}

public Name getName ()//Returns the name on the profile

{

return profileName;

}

/**

* Sets the name associated with the profile

* to the given first and last name.

*/

public void setName (String first, String last)//Sets to the name profileName

{

profileName.setName(first,last);

}

/**

* Sets the name associated with the profile

* to the given name.

*/

public void setName (Name name) //Sets the profile Name by taking in the actual name

{

profileName.setName(name.getFirst, name.getLast);

}

/**

* Sets the current status of the profile

* to the given string.

*/

public void setStatus (String stat) //Sets status of the string

{

status = stat;  

}

/**

* Returns the status associated with the profile.

*/

public String getStatus () //Gets the string which contain the status

{

return status;

}

/**

* Returns a list of all the profile's friends

*/

public AList < Profile > getFriends () //Gets all the friends list

{

return friends;

}

/**

* Adds a friend to the profile's list of friends.

*/

public void addFriend (Profile p)

{

friends.add(p);

}

/**

* Removes a friend from the profile's list of friends.

*/

public void removeFriend (Profile p) //For this I had like to modify the contain method of file 2

{ //so that it returns the index if found. It makes implementing this easy   

int index = -1;   

index = friends.contain(p);

if(index!=-1){

friends.remove(index);

}

  

}

public String toString () //Gives the imp info in form of a string

{

String ans;

ans = "Name: "+ profileName.getFirst + " " + profileName.getLast +" ";

ans = ans + "Status: " + status +" ";

ans = ans + "Picture: " + BufferedImage.getId + " "; //getId is not implemented here but it should return the id

ans = ans + "# of friends: " + friends.getLength + " ";

ans = ans + "Friends: " + " "

for(int i =0;i<friends.getLength;i++){

ans = ans + friends.getEntry(i) + " ";

}

}

/**

* Displays the profile's information and friends.

*/

public void display ()

{//Dont have any display method to show to the system. Therefore using println

  

String result = toString;

system.out.println(result);

}

} // end Profile

File 7:ProfileManager

/**

* A profile manager on a simple social network.

*/

  

public class ProfileManager

{

  

private final AList < Profile > allProfiles;

  

/**

* DO NOT CHANGE

* Constructor for an instance of a profile manager.

*/

public ProfileManager ()

{

  

/**

* DO NOT CHANGE

*/

allProfiles = new AList <> ();

  

}

/**

* Adds a profile onto the social network.

*/

public void addProfile (Profile p)

{

allProfiles.add(p);

}

/**

* Removes a profile from the social network.

*/

public void removeProfile (Profile p) //Again using the modified contain which returns the index of the found element

{ int index = -1;   

index = allProfiles.contains(p);

if(index !=-1){

allProfiles.remove(p);

}

  

}

/**

* Created a friendship between two profiles on the social network.

*/

public void createFriendship (Profile a, Profile b)//To create this, both the profiles should have each

{ // other's name in their lis tof friends.

a.friends.addFriend(b);

b.friends.addFriend(a);

  

}

/**

* Ends a friendship between two profiles on the social network.

*/

public void endFriendship (Profile a, Profile b)//For this remove the names from each ithers profile

{

a.friends.removeFriend(b);

b.friends.removeFriend(a);

  

}

/**

* Displays each profile's information and friends.

*/

public void display ()

{

for(int i=0;i<allProfiles.getLength();i++){

allProfiles[i].display;

}

}

}

Some suggestions are:

Sorry, I had not being able to attach any output to the question. Its because to configure and set up the project on a java project would take time more than the alloted 2hrs given to us. However the code should work perfectly fine. Let me know if u have any questions or better suggestions.