Question
The popular social network Facebook TM was founded by Mark Zuckerberg and his classmates at Harvard University in 2004. At the time, he was a
The popular social networkFacebookTMwas 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 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.
- You need to have a class diagram for your program (A simple one is acceptable):
Following are my projects? Could you help me add a class diagram for them? You can change the projects.
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 Listfriend=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 Listprofiles=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 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 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 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 get(dProfile).getFriend().size(); 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started