Lab Goal : This lab was designed to teach you how to use a Map. Lab Description : Take list of people and to whom each person is related. Then, build a list for each person and all of the people related to that person.
Please do this in JAVA
Note: The attached images are the instructions and the target output
relatives.dat file in text:
14
Jim Sally
Fred Alice
Jim Tom
Jim Tammy
Bob John
Dot Fred
Dot Tom
Dot Chuck
Bob Tom
Fred James
Timmy Amanda
Almas Brian
Elton Linh
Dot Jason
Dot
Relatives.java reference file:
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Scanner;
import static java.lang.System.*;
public class Relatives
{
private Map<String,Set<String>> map;
public Relatives()
{
}
public void setPersonRelative(String line)
{
String[] personRelative = line.split(" ");
}
public String getRelatives(String person)
{
return "";
}
public String toString()
{
String output="";
return output;
}
}
RelativesRunner.java reference file:
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
import static java.lang.System.*;
public class RelativesRunner
{
public static void main( String args[] ) throws IOException
{
//add more test cases
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images