The parameter inDir is the direction that you enter the intersection, and outDir is the direction that you will leave the intersection. This procedure returns only when it is safe to proceed through the intersection. Cars can proceed straight or make legal turns.
U turns are illegal.
If cars are waiting from both the north and east directions, they should proceed at the same time if they can safely do so. The east-west street has a single lane. You have no idea how long this procedure takes to execute. You should write three versions of the program. For all three of these programs, you should use the Java.