a Friend class that holds the first name, last name and hometown and the traditional methods
Use Graph to maintain a network of FriendsCreate and use a generic classSocial networks are everywhere! They connect people with other people. There is an internet meme called “The Six Degrees of Kevin Bacon”, which describes how movie actors are connected, directly or indirectly, with Kevin Bacon. Surprisingly, very short chains exist between any pair of actors, even obscure ones. For more information, see The Oracle of Kevin Bacon.You will be creating an application to maintain a network of friends. Follow the interfaces, the below specifications, and the JUnit test files.Data Element – Friend (Vertex)Create a Friend class that holds the first name, last name and hometown and the traditional methods (constructors, getters/setters, toString, etc.). It will implement the Comparable interface. This is the class header:public class Friend implements Comparable<Friend Data Element – Edge<T, SCreate a generic class Edge that can represent the edge of any Graph. T represents the data type of the first vertex and S represents the data type of the second vertex. The class must implement Comparable. The class stores references to both vertices and the traditional methods (constructors, getters/setters, toString, etc.), and a compareTo, which compares two Edge objects. Since this is a undirected graph, an edge from A to B is equal to an edge from B to A. This is the class header: public class Edge<T extends Comparable<T, S extends Comparable<S implements Comparable<Edge<T,SThe Data Structure – FriendGraph, implements GraphInterfaceCreate a FriendGraph class that implements the GraphInterface given you. Graph<V,E. V is the vertice type, E is the edge type. You will need to decide how to store the graph, use an adjacent matrix or adjacency list. This is the class header:public class FriendGraph implements Graph<Friend, Edge<Friend, Friend The Data Manager – implements DataManagerInterfaceYour Data Manager will hold an object of your FriendGraph. Implement the DataManagerInterface. There are methods to populate the graph (read from the participants and friends files), add a participant (vertices), add a friend (edge), list friends of a participant and list friends of friends of a participant. You may add any methods as needed for your design.Populating the Data StructureYou will be reading from two files: Participants.txt and Friends.txt.The Participants.txt holds the information for the individual participants (vertices), and is in the following format:FirstName:LastName:Hometown (delimiter of “:”)The Friends.txt holds the information for the friends of each participant (edges), and is in the following format:FirstName:LastName:# of friends:FriendFName:FriendLName:FriendFName:FriendLName: . . .This is an undirected graph which means that if there is an edge between Ann Abbott and Larry Lobster, then there is an edge between Larry Lobster and Ann Abbott. So that after the file has been read in, Ann may have more than the 3 friends listed here (Mark Miller lists Ann Abbott as a friend as well).After reading these files, you will have an initial set of vertices and edges in your FriendGraph. The GUIChoose a Profile – JComboBoxDisplay all the available participants in the JComboBox (in alpha order by last name). When the user selects one of the participants, display the first name, last name, hometown and friends. Populate the JComboBox for Add a Friend to include all participants except for the selected participant and the friends of the participant (in alpha order by last name).Show Friends of Friends ButtonDisplay all of the friends of the friends of the participant (in alpha order by last name, no duplicates). Do not include the participant or the friends of the participant.Add a Friend ButtonSelect one of the participants in the Add A Friend JComboBox. Add the friend to the participant (edge). The participants Friends text area will be updated to show the new friend. The Add A Friend JComboBox will no longer display the participant selected.Add new Profile ButtonEnter information for the first name, last name and hometown. Add the new participant (vertice) to the graph. Update the Choose a Profile and Add A Friend JComboBoxes to include the new participant.Exit ButtonThe program will terminate.
You'll get 1 file (38.1KB)