/* Road Network Simulator * Author: Douglas Jones * Status: Awful * Version: 9/8/2020 */ import java.util.LinkedList; import java.util.Scanner; /** * Roads connect intersections * @see Intersection */ class Road { float travelTime; Intersection destination; Intersection source; static final LinkedList allRoads = new LinkedList // BUG: Need a constructor // BUG: Need to maintain collection of all roads } /** * Intersections are connected by roads * @see Road */ class Intersection { String name; final LinkedList outgoing = new LinkedList (); final LinkedList incoming = new LinkedList (); static final LinkedList allIntersections = new LinkedList // BUG: Need a constructor // BUG: Need to maintain collection of all intersections // BUG: Need a lookup mechanism so roads can find their endpoints } /** * Main class builds model and will someday simulate it * @see Road * @see Intersection */ public class RoadNetwork { private void readNetwork( Scanner sc ) { static void readNetwork( Scanneer sc ) { while (sc.hasNext()) { // until the input file is finished string command = sc.next() if (command == "intersection") { // BUG: this if is wrong! new Intersection( sc, inters ); } else if (command == "road") { // BUG: this if is wrong! new Road( sc, inters ); } else { // Bug: Complain about unknown command } } } public static void main( String[] args ) { if (args.length < 1) { // BUG complain about missing args } else try { readNetwork( new Scanner( new File( args[0] ) ) ); // BUG do something here to prove we've read the network correctly! } catch ( FileNotFoundException e) { // BUG complain about file not found } } }