It's important project. I need a help. Will give up vote for helping! Please use Java !!!!!
Need clearly written java program code and sample output!!!!!!
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]
may needed
import java.util.Iterator;
public class UndirectedGraph extends DirectedGraph implements GraphInterface
{
public UndirectedGraph()
{
super();
}
public boolean addEdge(T begin, T end, double edgeWeight)
{
return super.addEdge(begin, end, edgeWeight) &&
super.addEdge(end, begin, edgeWeight);
} // end addEdge
public boolean addEdge(T begin, T end)
{
return this.addEdge(begin, end, 0);
} // end addEdge
public int getNumberOfEdges()
{
return super.getNumberOfEdges() / 2;
} // end getNumberOfEdges
public StackInterface getTopologicalOrder()
{
throw new UnsupportedOperationException("Topological sort illegal in an undirected graph.");
} // end getTopologicalOrder
} // end UndirectedGraph
Reference: Data Structures and Abstractions with Java, Frank M. Carrano, 4th Edition, Pearson, 2015.
public interface GraphInterface<T> extends BasicGraphInterface<T>,
GraphAlgorithmsInterface<T>
{
} // end GraphInterface
RunNetwork.java
import java.io.IOException;
import java.util.Scanner;
public class RunNetwork {
public static void main(String[] args)
{
Scanner input = new
Scanner(System.in);
int numberOfUsers;
Network robNetwork = new
Network();
System.out.println("Would you like
to initialize the Network with users? (y/n)");
String response =
input.nextLine();
if(response.equalsIgnoreCase("y"))
{
System.out.println("How many user would you like to
initialize?");
try {
numberOfUsers= input.nextInt();
} catch
(Exception e) {
System.out.println("Thats not a number, you get
no users");
numberOfUsers=0;
}
PeopleMaker.initializeNetwork(robNetwork,numberOfUsers);
PeopleMaker.makeFriends(robNetwork, numberOfUsers*2);
}
System.out.println();
Person newPerson = new
Person("SomeGuy");
System.out.println("Hello, welcome
to the network. Please choose an option below");
NetworkInterface yourInterface =
new NetworkInterface(robNetwork, newPerson);
yourInterface.start();
}
}
PeopleMaker.java
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Scanner;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class PeopleMaker {
public static void initializeNetwork(Network currentNetwork, int networkSize) {
currentNetwork.users =
makePeople(getNamesFromWeb(networkSize));
makeProfiles(currentNetwork);
System.out.println("Network
initialized with "
+ currentNetwork.users.size() + " users");
}
public static ArrayList<String>
getNamesFromWeb(int networkSize) {
ArrayList<String> names = new
ArrayList<String>();
URL nameSite;
try {
nameSite = new
URL(
"http://deron.meranda.us/data/census-dist-female-first.txt");
Scanner nameList
= new Scanner(nameSite.openStream());
for (int i =
0; i < networkSize; i++) {
if (nameList.hasNext()) {
names.add(parseNameLine(nameList.nextLine()));
System.out.println("Added
user #" + names.size()
+ names.get(names.size() - 1));
}
}
} catch (MalformedURLException e)
{
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("Done generating
Names");
return names;
}
public static String parseNameLine(String line)
{
String[] split = line.split("
");
return split[0];
}
public static ArrayList<Person>
makePeople(ArrayList<String> names) {
ArrayList<Person> people =
new ArrayList<>();
for (String name : names)
people.add(new
Person(name));
return people;
}
public static void makeProfiles(Network
currentNetwork) {
for (Person user :
currentNetwork.users) {
user.thisProfile = new Profile(currentNetwork, user.name,
new
StringBuilder(getRandomProfiles()));
System.out.println("Created Profile for User #"
+ user.thisProfile.id + ": "
+ user.name);
}
}
static int i=18;
public static String getRandomProfiles() {
Document doc;
try {
doc =
Jsoup
.connect(
"http://www.pof.com/basicsearch.aspx?iama=m&seekinga=f&minage="+Integer.toString(i)+"&maxage="+Integer.toString(i++))
.get();
Elements content
= doc.getElementsByClass("description");
String
randomStuff = content.get(0).ownText();
System.out.println(randomStuff);
if(i>45)
i=18;
return
randomStuff;
} catch (IOException e) {
// TODO
Auto-generated catch block
e.printStackTrace();
return
null;
}
}
public static void makeFriends(Network
currentNetwork, int numberOfFriends) {
for (int i = 0; i <
currentNetwork.users.size() * 2; i++) {
Person friend1 =
currentNetwork.users.get((int) Math.round(Math
.random() *
(currentNetwork.users.size() - 1)));
Person friend2 =
currentNetwork.users.get((int) Math.round(Math
.random() *
(currentNetwork.users.size() - 1)));
currentNetwork.makeFriends(friend1, friend2);
System.out.println(friend1.name + " has made friends with "
+ friend2.name);
}
}
}
Network.java
import java.util.ArrayList;
import java.util.Scanner;
public class Network {
ArrayList<Person> users = new
ArrayList<Person>();
private int userNumber;
Network(ArrayList<Person> people)
{
users=people;
}
Network(){};
public int incrementUserNumber()
{
return ++userNumber;
}
public void joinNetWork(Person newUser)
{
newUser.inNetwork = true;
newUser.thisProfile = new Profile(this);
newUser.name=newUser.thisProfile.userName;
users.add(newUser);
}
public void leaveNetwork(Person oldUser)
{
users.remove(oldUser);
oldUser.inNetwork=false;
}
public void makeFriends(Person user, Person newFriend)
{
user.friends.add(newFriend);
newFriend.friends.add(user);
}
public void showFriends(Person user)
{
for(Person friend: user.friends)
{
System.out.println(friend);
}
}
public Person searchProfiles(String name)
{
for(Person user: this.users)
{
if(user.thisProfile.userName.equalsIgnoreCase(name))
return
user;
}
return null;
}
}
Profile.java
import java.util.ArrayList;
import java.util.Scanner;
public class Profile {
String userName;
final int id;
StringBuilder aboutMe=new StringBuilder();
//ArrayList<String> aboutMe = new
ArrayList<String>();
Scanner input = new Scanner(System.in);
Profile(Network currentNetwork)
{
this.id=currentNetwork.incrementUserNumber();
editOrCreateProfile(currentNetwork);
}
void editOrCreateProfile(Network currentNetwork)
{
@SuppressWarnings("resource")
Scanner input = new Scanner(System.in);
System.out.println("Enter Name");
this.userName = input.nextLine();
System.out.println("Enter some stuff about
yourself");
System.out.println("press enter twice to
submit");
editAboutMe();
}
Profile(Network currentNetwork, String
name,StringBuilder aboutMe )
{
this.userName=name;
this.aboutMe=aboutMe;
this.id =
currentNetwork.incrementUserNumber();
}
void editAboutMe()
{
this.aboutMe= new
StringBuilder("");
while(input.hasNextLine())
{
String temp =
input.nextLine();
if(temp.equals(""))
break;
else
//this.aboutMe.add(temp+" ");
this.aboutMe.append(temp+"\n");
}
}
void viewProfile()
{
System.out.print("Name: ");
System.out.println(userName);
System.out.println("About
Me:");
printAboutMe();
}
void printAboutMe()
{
System.out.println(wrapString(aboutMe.toString(),"\n", 80));
System.out.println();
}
public static String wrapString(String s, String
deliminator, int length) {
String result = "";
int lastdelimPos = 0;
for (String token : s.split("
", -1)) {
if
(result.length() - lastdelimPos + token.length() > length)
{
result = result + deliminator + token;
lastdelimPos = result.length() + 1;
}
else
{
result += (result.isEmpty() ? "" : " ") + token;
}
}
return result;
}
}
NetworkInterface.java
import java.util.Scanner;
public class NetworkInterface {
Scanner input = new Scanner(System.in);
Network currentNetwork;
Person user;
NetworkInterface(Network currentNetwork, Person
user) {
this.currentNetwork =
currentNetwork;
this.user = user;
}
public void start() {
String response;
do {
// if
(!user.inNetwork) {
System.out
.println("M: Make profile\t S: Search profiles\t L: Login\tQ: Quit
");
// } else
//
System.out.println("S: Search profiles\t L:
Login\tQ: Quit ");
response =
input.nextLine();
if
(response.equalsIgnoreCase("M"))
currentNetwork.joinNetWork(user);
else if
(response.equalsIgnoreCase("S"))
searchProfilesMenu();
else if
(response.equalsIgnoreCase("L"))
logIn();
} while
(!response.equalsIgnoreCase("q"));
System.out.println("Ending
Session");
}
void searchProfilesMenu() {
String response;
do {
System.out.println("Enter a name to look for\tQ: Quit ");
response =
input.nextLine();
if
(!response.equalsIgnoreCase("q")) {
Person query =
currentNetwork.searchProfiles(response);
if (query == null)
System.out.println("That user
does not exist");
else
query.thisProfile.viewProfile();
System.out.println();
}
} while
(!response.equalsIgnoreCase("q"));
}
Person getPersonMenu() {
String response;
do {
System.out.println("Enter a name to look for\tQ: Quit ");
response =
input.nextLine();
if
(!response.equalsIgnoreCase("q")) {
Person query =
currentNetwork.searchProfiles(response);
if (query == null)
System.out.println("That user
does not exist");
else
return query;
System.out.println();
}
} while
(!response.equalsIgnoreCase("q"));
return null;
}
void logIn() {
String response;
do {
System.out.println("Please type your username to log in.\tQ:
quit");
response =
input.nextLine();
if
(currentNetwork.searchProfiles(response) != null)
loggedInMenu(currentNetwork.searchProfiles(response));
break;
} while
(!response.equalsIgnoreCase("Q"));
}
void loggedInMenu(Person user) {
System.out.println("Hello " +
user.thisProfile.userName);
String response;
do {
System.out
.println("V: view your
profile\t E: Edit profile\t S: Search profiles\tF: View
friends\t A: Add Friends \tL: Logout ");
response =
input.nextLine();
if
(response.equalsIgnoreCase("V"))
user.thisProfile.viewProfile();
else if
(response.equalsIgnoreCase("S"))
searchProfilesMenu();
else if
(response.equalsIgnoreCase("E"))
user.thisProfile.editOrCreateProfile(currentNetwork);
else if
(response.equalsIgnoreCase("A"))
user.addFriends(getPersonMenu());
else if
(response.equalsIgnoreCase("F"))
user.viewFriends();
} while
(!response.equalsIgnoreCase("L"));
}
}
Person.java
import java.util.ArrayList;
public class Person {
ArrayList<Person> friends = new
ArrayList<Person>();
boolean inNetwork = false;
String name;
Profile thisProfile;
Person(String name) {
this.name = name;
}
public void addFriends(Person newFriend) {
this.friends.add(newFriend);
newFriend.friends.add(this);
System.out.println("You've added "
+ newFriend.name + " as a friend");
}
public void viewFriends()
{
for(Person friend: friends)
System.out.println(friend.name);
}
}
It's important project. I need a help. Will give up vote for helping! Please use Java !!!!! Need ...
Please try your best to complete this 11 methods under. I have provided the UndirectedGraph class with the single instance data variable. Do not add any additional instance data variables. Do not modify any other classes provided. In addition to writing the 8 required methods of the interface and the constructor, you will also write methods for the two traversals and an isConnected method. import java.util.Queue; public class UndirectedGraph<T> implements BasicGraphInterface <T> { private DirectedGraph digraph; ...
I need help with this project: Code provided: HOUSEGRAPH.java public class HouseGraph extends LinkedGraph { // establish rooms private final Location kitchen = new Location("Kitchen"); private final Location pantry = new Location("Pantry"); private final Location diningRoom = new Location("Dining Room"); private final Location backFoyer = new Location("Back Foyer"); private final Location frontFoyer = new Location("Front Foyer"); private final Location study = new Location("Study"); private final Location livingRoom = new Location("Living Room"); private final Location stairs = new Location("Stairs"); private final...
Java. Must not use Java API java.util.Stack /** A class of stacks whose entries are stored in an array. Implement all methods in ArrayStack class using resizable array strategy, i.e. usedoubleArray() Must throw StackException during exception events in methods: peek(), pop(), ArrayStack(int initialCapacity) Do not change or add data fields Do not add new methods */ import java.util.Arrays; public class Arraystack«Т> implements Stack!nterface«T> private TI stack;// Array of stack entries private int topIndex; /7 Index of top entry private static...
Java help: Please help complete the locate method that is in bold.. public class LinkedDoubleEndedList implements DoubleEndedList { private Node front; // first node in list private Node rear; // last node in list private int size; // number of elements in list ////////////////////////////////////////////////// // YOU MUST IMPLEMENT THE LOCATE METHOD BELOW // ////////////////////////////////////////////////// /** * Returns the position of the node containing the given value, where * the front node is at position zero and the rear node is...
Java. Must not use Java API java.util.Stack /** A class of stacks whose entries are stored in an array. Implement all methods in ArrayStack class using resizable array strategy, i.e. usedoubleArray() Must throw StackException during exception events in methods: peek(), pop(), ArrayStack(int initialCapacity) Do not change or add data fields Do not add new methods */ import java.util.Arrays; public class Arraystack«Т> implements Stack!nterface«T> private TI stack;// Array of stack entries private int topIndex; /7 Index of top entry private...
// I need help with the following questions. Please use java programming ECLIPSE language to solve the questions. YOU ONLY NEED TO DIRECTLY COPY IT IN YOUR ECLIPSE APPLICATION AND RUN IT. I NEED THOSE PART WHICH IS SAYS --> "TO BE COMPLETED" I NEED HELP WITH [GET*] AND [REPLACE ALL] AND [ADD INT DOUBLE] PLEASE. import java.util.ArrayList; public class CustomArrayList { //instance variables public int[] data; //data.length gives the capacity public int nItems; //nItems gives items currently in the...
Java: Return an array of booleans in a directed graph. Please complete the TODO section in the mark(int s) function import algs13.Bag; import java.util.HashSet; // See instructions below public class MyDigraph { static class Node { private String key; private Bag<Node> adj; public Node (String key) { this.key = key; this.adj = new Bag<> (); } public String toString () { return key; } public void addEdgeTo (Node n) { adj.add (n); } public Bag<Node> adj () { return adj;...
Please help with this Java Program. Thank you! we will be implementing an Ordered List ADT. Our goal is to implement the interface that is provided for this ADT. Notice that there are two interfaces: OrderedListADT builds on ListADT. In this homework, you'll only be responsible for the OrderedListADT. Figure 1: UML Overview 1 Requirements Create a doubly linked implementation of the OrderedListADT interface. Note that the book includes most of the source code for a singly linked implementation of...
I have a Graph.java which I need to complete four methods in the java file: completeGraph(), valence(int vid), DFS(int start), and findPathBFS(int start, int end). I also have a JUnit test file GraphTest.java for you to check your code. Here is Graph.java: import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; import java.util.Stack; /* Generic vertex class */ class Vertex<T> { public T data; public boolean visited; public Vertex() { data = null; visited = false; } public Vertex(T _data) { data =...
Need help with this Java project implementing an interpolation search, bolded the missing parts: /** A class that implements an interpolation search and a binary search of a sorted array of integers. @author Frank M. Carrano @author Timothy M. Henry @version 4.0 */ public class SearchComparer { private int[] a; private int interpolationSearchCounter; private int binarySearchCounter; private static final int CAPACITY = 50; public SearchComparer(int[] array, int n) {...