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

It\'s important project. I need a help. Please use Java The popular social netwo

ID: 3908368 • Letter: I

Question

It's important project. I need a help.

Please use Java

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 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, 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.

[Project 16 Chapter 13 - A List Implementation That Uses an Array]

Repeat Project above to create a simple social network. Use a graph to track the friend relationships among members of the network. Add a feature to enable people to see a list of their friends’ friends.

[Project 9 Chapter 29 - Graph Implementations]

Explanation / Answer

import java.io.*;
import java.util.*;


class Member {

   private String name;
   private String currentStatus;
   private Member next;

   public Member(String n){
         name = n;
         currentStatus = "Active";
         next = null;
   }
   String getName(){
       return name;
   }
   String getStatus(){
       return currentStatus;
   }
   public void setStatus(String a){
      currentStatus = a;
   }
   public void setName(String a){
      name = a;
   }
   public void addFriend (String a){
       Member m = new Member(a);

       if (next == null){
          next = m;
       }
       else {
           Member p = next;
           while (p.next != null)
                 p = p.next;
           p.next = m;
       }       
   }
   public void displayFriends (){
      

       if (next == null){
          System.out.println("No friends");
       }
       else {
           Member p = next;
           while (p!= null){
                 System.out.println(p.getName());
                 p = p.next;
           }
          
       }       
   }

  
}

class UserDatabase{
      private ArrayList<Member> list;

      public UserDatabase(){
           list = new ArrayList<Member>();
      }

      public void addMember(){
           Scanner sc = new Scanner(System.in);
           System.out.println("Enter name:");
           String line = sc.nextLine();
           Member m = new Member(line);
           list.add(m);
      }
      public void removeMember(){
           Scanner sc = new Scanner(System.in);
           System.out.println("Enter name:");
           String line = sc.nextLine();
           int found = 0;
           for (int i = 0; i < list.size();i++){
                if (list.get(i).getName().equals(line)){
                   list.remove(i);
                   found = 1;
                }
           }
           if (found == 0){
              System.out.println("Not Found");
           }
         
      }
      public void searchMember(){
           Scanner sc = new Scanner(System.in);
           System.out.println("Enter name:");
           String line = sc.nextLine();
           int found = 0;
           for (int i = 0; i < list.size();i++){
                if (list.get(i).getName().equals(line)){
                   System.out.println("Name:" + line);
                   System.out.println("Status:" + list.get(i).getStatus());
                   found = 1;
                }
           }
           if (found == 0){
              System.out.println("Not Found");
           }
         
      }
      public void modifyMember(){
           Scanner sc = new Scanner(System.in);
           System.out.println("Enter name:");
           String line = sc.nextLine();
           int found = 0;
           for (int i = 0; i < list.size();i++){
                if (list.get(i).getName().equals(line)){
                    System.out.println("Enter new name:");
                    line = sc.nextLine();
                    list.get(i).setName(line);
                   found = 1;
                }
           }
           if (found == 0){
              System.out.println("Not Found");
           }
         
      }  
      public void displayFriends(){
           Scanner sc = new Scanner(System.in);
           System.out.println("Enter name:");
           String line = sc.nextLine();
           int found = 0;
           for (int i = 0; i < list.size();i++){
                if (list.get(i).getName().equals(line)){
                   list.get(i).displayFriends();
                   found = 1;
                }
           }
           if (found == 0){
              System.out.println("Not Found");
           }
         
      }
}

public class DemoSocial {

   public static void main(String[] args){

       Scanner sc = new Scanner(System.in);
       UserDatabase db = new UserDatabase();
       while(true){
            System.out.println("1.Create a profile");
            System.out.println("2.Leave the network");
            System.out.println("3.Search Profile");
            System.out.println("4.Modify Profile");
            System.out.println("5.Display friends list");
            System.out.println("6.Exit");
            System.out.println("Enter choice:");
            int n = Integer.parseInt(sc.nextLine());
            if (n == 6)
               break;
            else if (n == 1)
                 db.addMember();
            else if (n == 2)
                 db.removeMember();
            else if (n == 3)
                 db.searchMember();
            else if (n == 4)
                 db.modifyMember();
            else if (n == 2)
                 db.displayFriends();
                
           
       }       
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote