Question: 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

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 image(extra credit), current status(Online, offline, busy,...), and a list of friends. Your application should allow a user to join the network, leave the network, create profile, modify the profile, search for other profiles, and add and remove friends.

use java

You need to implement CRUD (Incomputer programming,create, read, update, and delete(CRUD) are the four basic functions):

C= Create: Add profile- Add friends

R= Read: Read the information of a profile - Search for other profiles

U= Update: Update and edit the profile - Update the friend list

D= Delete: Delete a profile - Delete a friend of a profile.

Repeat the Project above to create simple social network.Use a graph to track friend relationships among members of the network.Add a feature to enable people to see a list of their friends' friends. You need to useat leastone graph data structure

Following are my projects without graph. Need a graph data structure.

Profile class

import java.util.ArrayList;

import java.util.List;

public class Profile {

public Profile(String name) {

this.name=name;

this.status="Online";

}

private String name;

private String image;

private String status;

private List friend=new ArrayList();

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getImage() {

return image;

}

public void setImage(String image) {

this.image = image;

}

public String getStatus() {

return status;

}

public void setStatus(String status) {

this.status = status;

}

public List getFriend() {

return friend;

}

public void setFriend(List friend) {

this.friend = friend;

}

public void addFriend(Profile profile) {

this.friend.add(profile);

}

@Override

public String toString() {

StringBuilder builder = new StringBuilder();

builder.append("[name=");

builder.append(name);

builder.append(", image=");

builder.append(image);

builder.append(", status=");

builder.append(status);

builder.append(", friend=");

builder.append(friend);

builder.append("]");

return builder.toString();

}

}

Test.java

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

public class Test2 {

private static List profiles=new ArrayList();

public static void main(String[] args) {

Scanner scanner=new Scanner(System.in);

System.out.println("Please select option: ");

System.out.println("1 for Add a new Profile ");

System.out.println("2 for Search Profiles ");

System.out.println("3 for Update and edit the profile ");

System.out.println("4 for Delete a profile ");

System.out.println("-1 for quit ");

int iProfile=scanner.nextInt();

if(iProfile==-1) {

scanner.close();

return;

}else if(iProfile==1) {

System.out.println("Please enter name for profile : ");

String name=scanner.next();

if(name!=null && name.trim()!="") {

Profile profile=new Profile(name);

System.out.println("Please enter profile picture url :");

String profilePicture=scanner.next();

profile.setImage(profilePicture);

profiles.add(profile);

}

main(new String[] {});

}else if(iProfile==2) {

System.out.println("Profile at this Network");

for(Profile profile: profiles) {

System.out.println(profile);

}

main(new String[] {});

}else if(iProfile==3) {

System.out.println("Please select profile which you want to update: ");

for(int i=0; i

System.out.println(i+" for "+profiles.get(i));

}

System.out.println("-1 for return to main menu");

int uProfile=scanner.nextInt();

if(uProfile==-1) {

main(new String[] {});

}else {

Profile profile=profiles.get(uProfile);

System.out.println("select profile adding friend");

for(int i=0; i

System.out.println(i+" for "+profiles.get(i));

}

System.out.println("-1 for return to main menu");

int fProfile=scanner.nextInt();

if(fProfile==-1) {

main(new String[] {});

}else {

profile.addFriend(profiles.get(fProfile));

main(new String[] {});

}

}

}else if(iProfile==4) {

System.out.println("Please select profile whose friend you want to delete");

for(int i=0; i

System.out.println(i+" for "+profiles.get(i));

}

System.out.println("-1 for return to main menu");

int dProfile=scanner.nextInt();

if(dProfile==-1) {

main(new String[] {});

}else {

System.out.println("select friend of "+profiles.get(dProfile).getName()+" want to delete");

for(int i=0; i

System.out.println(i+" for "+profiles.get(dProfile).getFriend().get(i));

}

System.out.println("-1 for return to main menu");

int aProfile=scanner.nextInt();

if(aProfile==-1) {

main(new String[] {});

}else {

profiles.get(dProfile).getFriend().set(aProfile, 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!