Machine Problem 2, due Feb. 18

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

Data Format: As described in Homework assignment 4, the input data format for our logic simulator will eventually be something like this:

gate a xor 6.7
gate b threshold 1 3.6
wire a 3.2 b
wire b 1.5 a 1.8 a
gate c xor 1.5

Initially, we will simplify this, so for MP2, you should expect a format like this:

gate a
gate b
wire a 3.2 b
wire b 1.5 a 1.8 a
gate c

Explanation: Gates have no attributes other than their name. Wire definitions hav a source gate, and any number of destinations, where each destination is preceeded by the delay to that destination so if you use a scanner to read the file, the scanner's hasNextFloat method can be used to see if there is another destination for the wire. Note that the following input file describes exactly the same circuit as the above:

gate a
gate b
gate c
wire a 3.2 b
wire b 1.5 a
wire b 1.8 a

Assignment: Write a Java program in file MP2.java that reads a logic circuit description such as later two given above, builds a data structure describing this circuit using gate and wire objects, and then traverses the data structure and outputs the circuit.

The outut should list all gates first and all wires second, regardless of how they were shuffled in the initial input, where the only constraint is that gates be declared before wires are connected to them. So, the final example above is an appropriate output if the second example above is given as input.

Requirements: Aside from correct operation of your program, you are expected to:

Submission: To submit your work, it must be in a file named MP2.java in your current directory on the CLAS Linux system, and you must know your discussion section number. Follow the submission instructions from MP1, but of course, use the mp2 submission directories.