Create a public class Connections with a single public constructor that accepts a String. The String contains, in CSV format, a list of cities and other cities that they are connected to. So, for example, the input: Champaign,Chicago,St. Louis Chicago,Detroit,Milwaukee St. Louis,Champaign,Cincinnati Means that Champaign is connected to Chicago and St. Louis, and that Chicago is connected to Detroit and Milwaukee, and so on. Essentially the CSV serializes a directed graph, where the first item on each line is a node and the other items represent other nodes that it is connected to. This is one way of serializing a directed, unweighted graph. If the String passed to the constructor is null, throw an IllegalArgumentException. Make sure to trim all the Strings that you extract from the CSV. Your class should parse this String and provide a single instance method isConnected. isConnected accepts two Strings and returns true if the first city is connected to the second based on the graph passed to the constructor. So, given the input above, isConnected ("Champaign", "Chicago") would return true, but isConnected("Chicago", "Champaign") would return false. (Note that the graph is not necessarily symmetric.) If either String passed to isConnected is null, or if you don't have connection information for the source, you should throw an IllegalArgumentException. Note that only the cities that appear first on each line in the CSV should be treated as cities you have connection information for. So, for example, even though "Detroit" appears as a destination from "Chicago" in the data set above, we do not have a line starting with "Detroit", and therefore a call to isConnected with "Detroit" as the first parameter should throw an IllegalArgumentException.
Create a public class Connections with a single public constructor that accepts a String. The String contains, in CSV format, a list of cities and other cities that they are connected to. So, for example, the input: Champaign,Chicago,St. Louis Chicago,Detroit,Milwaukee St. Louis,Champaign,Cincinnati Means that Champaign is connected to Chicago and St. Louis, and that Chicago is connected to Detroit and Milwaukee, and so on. Essentially the CSV serializes a directed graph, where the first item on each line is a node and the other items represent other nodes that it is connected to. This is one way of serializing a directed, unweighted graph. If the String passed to the constructor is null, throw an IllegalArgumentException. Make sure to trim all the Strings that you extract from the CSV. Your class should parse this String and provide a single instance method isConnected. isConnected accepts two Strings and returns true if the first city is connected to the second based on the graph passed to the constructor. So, given the input above, isConnected ("Champaign", "Chicago") would return true, but isConnected("Chicago", "Champaign") would return false. (Note that the graph is not necessarily symmetric.) If either String passed to isConnected is null, or if you don't have connection information for the source, you should throw an IllegalArgumentException. Note that only the cities that appear first on each line in the CSV should be treated as cities you have connection information for. So, for example, even though "Detroit" appears as a destination from "Chicago" in the data set above, we do not have a line starting with "Detroit", and therefore a call to isConnected with "Detroit" as the first parameter should throw an IllegalArgumentException.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education