Assignment 11, due Nov. 13Solutions
Part of
the homework for CS:2820, Fall 2015
|
A Problem: Give an example circuit that clearly demonstrates the inadequacy of this solution, either because it would produce no output or because it would produce misleading output. (The circuit need not have complex or interesting behavior -- the only thing it must do is demonstrate the incorrectness of the proposed solution.) (1 point)
gate and a 1.0 gate output b 0.0 wire a a in1 1.0 wire a a in2 1.0 wire a b in 1.0
The notable thing about this circuit is that nothing ever changes, so there will be no output change events anywhere in the circuit. The correct output, however, would be:
b |
A Problem: Find and explain this logic. (1 point)
private static void readCircuit( Scanner sc ) { /** Read a logic circuit, scanning its description from sc. */ while (sc.hasNext() && !sc.hasNextFloat()) {
The test, at the start of each line, for hasNextFloat() terminates the reading of the circuit description, leaving the scanner positioned to read the list of input change events.
A Problem: With input gates, is there a need for a similar static readInput() method, or should this job be done by some kind of inputChange() event that is specific to one particular input gate at a time? Explain why. (1 point)
Each line of input looks like this:
1.0 a true