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:
*/
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;
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
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. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
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
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