Java homework
Write a Java program, in file Logic.java that meets all of the requirements for MP3, except that, if there are no errors in the input file, it runs a simulation of the behavior of the input as follows:
wire
Any change on the input to a wire occurs at the output of that wire after the delay of that wire. All wires initially carry the value false, so all gate inputs and outputs are initially false.
not
Any change to the input of the not gate appears inverted at the output after the delay of the gate. This means that the output will change to true at least briefly exactly one gate delay after the start of the simulation.
and
If, as a result of an input change, both inputs become true, the output will change to true after the gate's delay. If an input change causes this to be no longer the case, the output will change to false after the gate's delay.
or
If, as a result of an input change, both inputs become false, the output will change to false after the gate's delay. If an input change causes this to be no longer the case, the output will change to true after the gate's delay.
const
The false output is initally false and stays false forever. The true output is initially false and becomes true after the gate delay. From then on, it remains true.
If there are no errors in the input, the output of your program should be a sequence of reports of gate output changes, one line per report. For example, if at time 0.7, the output out of gate A changes to true you should report:
0.7: A out true
Note that some input circuits will generate infinite outputs, while others will eventually reach a stable state after which nothing occurs, allowing the simulation to terminate.
Grading criteria: No credit will be given to programs that do not represent a substantial attempt at meeting the requirements of this assignment. Your program must:
· Begin with a header comment giving the source file name.
· Contain appropriate Javadoc or other comments claiming authorship and declaring the version to be MP3.
· Be cleanly and readably indented.
· Use appropriate variable names.
· Respond appropriately to errors in the input.
· Not demonstrate any unhandled or mishandled exceptions.
· Properly demonstrate a simulation of the input circuit.
Note that MP4 will involve extending MP3 to simulate the behavior of gates, so planning for this, while not part of this assignment, may simplify the next.
Note that the requirements for header comments in the file header are absolute. Your name must appear in the form that it appears on your ID card. The TAs will not waste their time doing detective work to attempt to figure out who submitted what code.
Submission: Your solution should consist of a single file named Logic.java, with a public method, main. (We will chop the file into smaller more managable pieces later, as it grows.)