logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Modify this project Network.java Use a graph to track friend relationships among members of the network

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Modify this project Network.java
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 use One graph data structure
You may need all the files from the "Graphs - Directed Weighted" and UndirectedGraph.java

You must not use any java library such as:

import java.util.ArrayList;
import java.util.List; 

import.java.util.graph

because You must use your own data structure

The program create a network and ask the user to do below options:

  1. exit
  2. Create a new profile
  3. Modify a profile
  4. Delete a profile
  5. Search a profile
  6. Add friend to a profile
  7. Remove friend from a profile
  8. Update friend list

*/

import java.util.Scanner;

 

public class Network {

    MyArrayList profile = new MyArrayList();

 

    public MyArrayList getProfile() {

        return profile;

    }

 

    public void setProfile(MyArrayList profile) {

        this.profile = profile;

    }

 

    public static void main(String[] args) {

        Network network = new Network();

        Scanner sc = new Scanner(System.in);

        System.out.println("Welcome to the network");

        boolean quit = false;

        while (true) {

            System.out.println("nPlease select your option" + "n0. Exit" + "n1. Create a new profile"

                    + "n2. Modify a profile" + "n3. Delete a profile" + "n4. Search a profile"

                    + "n5. Add friend to a profile" + "n6. Remove friend from a profile" + "n7. Update friend list");

            String choice = sc.nextLine();

            int selection = Integer.parseInt(choice);

            switch (selection) {

                case 1:// create a profile

                    System.out.println("Enter your username");

                    String name = sc.nextLine();

                    System.out.println("Please enter the status: ");

                    String status = sc.nextLine();

                    PersonProfile profile = network.createProfile(name, status);

                    network.getProfile().add(profile);

                    System.out.println("Person profile succesfully created");

                    System.out.println("nProfile details:n" + profile.toString());

                    break;

 

                case 2:// Update a profile

                    System.out.println("Enter the username");

                    network.modifyProfile(sc.nextLine());

                    break;

 

                case 3:// delete a profile

                    System.out.println("Enter the profile name");

                    network.deleteProfile(sc.nextLine());

                    break;

 

                case 4:// Read or search a profile

                    System.out.println("Enter the profile name");

                    PersonProfile s = network.searchProfile(sc.nextLine());

                    if (s == null)

                        System.out.println("Non-existing profile");

                    else

                        System.out.println("nProfile details:n" + s.toString());

                    break;

                case 5:// add friend to a profile

                    System.out.println("Enter the profile name you want to add friends");

                    PersonProfile p = network.searchProfile(sc.nextLine());

                    if (p == null)

                        System.out.println("You can't add friends to a non existing profile");

                    else {

                        while (true) {

                            System.out.println("Enter the friend name");

                            PersonProfile friend = network.searchProfile(sc.nextLine());

                            if (friend == null)

                                System.out.println("No such friend profile exist");

                            else {

                                p.addFriend(friend);

                                System.out.println(p.getPersonName() + " profile details:n" + p.toString());

                            }

                            System.out.println("Do you wish to add another friend for this profile (y/n)");

                            if (sc.nextLine().equalsIgnoreCase("n"))

                                break;

                        }

 

                    }

                    break;

 

(5/5)
Attachments:

Expert's Answer

536 Times Downloaded

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

536 Times Downloaded

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

971 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

662 Answers

Hire Me
expert
Husnain SaeedComputer science

804 Answers

Hire Me
expert
Atharva PatilComputer science

631 Answers

Hire Me

Get Free Quote!

290 Experts Online