logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

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

expert
Jayden StewarttHistory
(4/5)

740 Answers

Hire Me
expert
Anuj MittalMathematics
(/5)

597 Answers

Hire Me
expert
Cristopher WebbTechnical writing
(5/5)

642 Answers

Hire Me
expert
Robin HunterGeneral article writing
(5/5)

901 Answers

Hire Me
Java Programming

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;

 

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. 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

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme