Machine Problem 5, due Apr 17

Part of the homework for CS:2820, Spring 2017
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Take the version of TernaryLogic.java distributed as a solution to MP4 and break it into multiple source files. Then add the following new code to class TernaryLogic:

	private static float printInterval;

	public static void initPrint( float i ) {
		printInterval = i;
		Simulation.schedule(
			0.0f,
			(float t) -> printGates( time t );
		)

		for( Gate g: gates ) {
			System.out.print( " " + g.name );
		}
		System.out.println();
	}

	private static void printGates( float time ) {
		for( Gate g: gates ) {
			System.out.print( " " + g.printValue() );
		}
		System.out.println();

		Simulation.schedule(
			time + printInterval,
			(float t) -> printGates( time t );
		)
	}
}

The value of printInterval should be initialized from the command line, and initPrint should be called right before running the simulation.

Your job is to modify class Gate, eliminating the code to print output that was there for MP4 and adding a printValue() method that returns one of the following strings:

The point of this is that you might get output such as the following:

 TIMER CLOCK ENABL
   |    _|     |_
   |   |___      |
   |    ___|     |
  _|   |___      |
 |      ___|  ___|
 |     |     |

This output is a graph of the values of the outputs of the gates, turned on its side so time goes down the page.

Submission Instructions: Your code for class Gate should be in a single file called Gate.java, with no other methods in that file but class Gate. Submit just this one file, not the whole program! On-line submission will be accepted as in the previous machine problems, in th mp5 submission directory.

As usual, you will be graded on whether your code works and on the cosmetics of that code.