Question: 2. The Network class. The network represents the social network of entities. The Network class should implement the Iterable interface and should contain a linked

2. The Network class. The network represents the social network of entities. The Network class should implement the Iterable interface and should contain a linked list that stores all the entities of the network. The Iterator for the network should iterate over all the entities in the network. The Network class contains the following methods: 1. addRelation takes two Entity objects. If either entity is not in the network, it is added to the network. (There should not be duplicate entities in the network.) Then, for each entity, add the other entity to its relations list 2. removeRelation takes two Entity objects. Each entity is removed from the other's relations list. The entities are not removed from the network 3. addRelations takes a File parameter. The file contains a list of relations. Each relation will be a pair of names. The names of a relation pair are separated by a comma, and each relation pair is on its own line. For example University Hospitals, Cleveland Clinc University Hosptials, Louis Stokes Cleveland VA Medical Center Cleveland Clinic, Mercy Regional Medical Center The method may throw an exception if there is a problem with the file. Each pair of names should be added to the network as a relation of Entity objects with those names 4. addRelations takes a variable length parameter of strings. There should be an even number of strings. An exceptioin may be thrown if there is not an even number. The method should create Entity instances for each string and for each pair of names (first two names, second two names, etc.) the pair of entities should be added to the network as a relation. The Network class should have a constructor that takes no input and initializes an empty network 2. The Network class. The network represents the social network of entities. The Network class should implement the Iterable interface and should contain a linked list that stores all the entities of the network. The Iterator for the network should iterate over all the entities in the network. The Network class contains the following methods: 1. addRelation takes two Entity objects. If either entity is not in the network, it is added to the network. (There should not be duplicate entities in the network.) Then, for each entity, add the other entity to its relations list 2. removeRelation takes two Entity objects. Each entity is removed from the other's relations list. The entities are not removed from the network 3. addRelations takes a File parameter. The file contains a list of relations. Each relation will be a pair of names. The names of a relation pair are separated by a comma, and each relation pair is on its own line. For example University Hospitals, Cleveland Clinc University Hosptials, Louis Stokes Cleveland VA Medical Center Cleveland Clinic, Mercy Regional Medical Center The method may throw an exception if there is a problem with the file. Each pair of names should be added to the network as a relation of Entity objects with those names 4. addRelations takes a variable length parameter of strings. There should be an even number of strings. An exceptioin may be thrown if there is not an even number. The method should create Entity instances for each string and for each pair of names (first two names, second two names, etc.) the pair of entities should be added to the network as a relation. The Network class should have a constructor that takes no input and initializes an empty network
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
