In this lab, you will experiment with maps and sets in Java.
Create a project in Eclipse named Lab11 with a class named MapSetTester with a main method. You will be using the HashMap and TreeSet classes, so open up the Java API so you can refer to the documentation for these classes as you work on these problems.
HashMap<______,______> networkMap = new HashMap<______,______>();
After you update the hash map, output the contents of the hash map (i.e. System.out.println(networkMap); ). Repeat this until 10 shows have been entered.
Sample Output (note how the networks are not necessarily in lexicographic order, but the television shows for each network are in lexicographic order... why?):
Input tv network: FOX Input tv show on FOX: The Simpsons {FOX=[The Simpsons]} Input tv network: NBC Input tv show on NBC: ER {FOX=[The Simpsons], NBC=[ER]} Input tv network: ABC Input tv show on ABC: 20/20 {FOX=[The Simpsons], NBC=[ER], ABC=[20/20]} Input tv network: CBS Input tv show on CBS: Survivor {CBS=[Survivor], FOX=[The Simpsons], NBC=[ER], ABC=[20/20]} Input tv network: ABC Input tv show on ABC: Lost {CBS=[Survivor], FOX=[The Simpsons], NBC=[ER], ABC=[20/20, Lost]} Input tv network: FOX Input tv show on FOX: Family Guy {CBS=[Survivor], FOX=[Family Guy, The Simpsons], NBC=[ER], ABC=[20/20, Lost]} Input tv network: CBS Input tv show on CBS: CSI {CBS=[CSI, Survivor], FOX=[Family Guy, The Simpsons], NBC=[ER], ABC=[20/20, Lost]} Input tv network: FOX Input tv show on FOX: American Idol {CBS=[CSI, Survivor], FOX=[American Idol, Family Guy, The Simpsons], NBC=[ER], ABC=[20/20, Lost]} Input tv network: ABC Input tv show on ABC: Desperate Housewives {CBS=[CSI, Survivor], FOX=[American Idol, Family Guy, The Simpsons], NBC=[ER], ABC=[20/20, Desperate Housewives, Lost]} Input tv network: NBC Input tv show on NBC: Law And Order {CBS=[CSI, Survivor], FOX=[American Idol, Family Guy, The Simpsons], NBC=[ER, Law And Order], ABC=[20/20, Desperate Housewives, Lost]}
Sample output:
ABC: [20/20, Desperate Housewives, Lost] CBS: [CSI, Survivor] FOX: [American Idol, Family Guy, The Simpsons] NBC: [ER, Law And Order]
HINT: Iterate over each key (network) in the map, and see if its value (set of shows) contains the desired show. If so, print out the network. Otherwise, if none of the networks have that show, report "UNKNOWN". You don't have to worry about uppercase/lowercase, just match the TV show name exactly.