Question: import java.io.File; import java.util.LinkedList; import java.util.Scanner; /** Roads are one-way streets linking intersections * @see Intersection */ class Road { float travelTime; //measured in seconds

import java.io.File; import java.util.LinkedList; import java.util.Scanner; /** Roads are one-way streets linking intersections * @see Intersection */ class Road { float travelTime; //measured in seconds Intersection destination; //where the road goes Intersection source; //where the comes from // name of road is source-destination } /** Intersections join roads * @see Road */ class Intersection { String name; LinkedList  outgoing = new LinkedList  (); LinkedList  incoming = new LinkedList  (); // Bug: multiple types of intersections (uncontrolled, stoplight) /** RoadNetwork, the main class to build a network of roads and intersections. * @see Road * @see Intersection */ public class RoadNetwork { public static void main(String[] args) { // Bug: Must add code to see if there is a file name Scanner sc = new Scanner( new File( args[0] ) ); // Bug: What if the file doesn't exist? } } 

Background: Now consider the problem of representing, inside the computer, a connection from a road to or from a particular incoming connection to an intersection. There are numerous solutions! First consider going perhaps a bit overboard and having a separate object for each lane in and out of an interesection. Where we used to have just one intersection object, we how have a constellation of objects, one central one for the intersection itself, and one for each lane in and out of that intersection.

A Problem: How would this change the definition of class Road. Concentrate on changes to the data, ignore changes in the methods.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!