Machine Problem 3, due Mar 6

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

Write a Java program, in file TernaryLogic.java that can be run as follows to read data from a file called f (presuming that this file exists):

[HawkID@serv15 project]$ java TernaryLogic f

When your program is run, it should read a description of a network of ternary logic gates and wires. The allowed gate types should be min, max, neg, istrue, isfalse, and isunknown. Here is an example description (a refinement of the file format discussed in Homework 4 problem 2):

gate A min 4 1.0
gate B max 2 0.5
wire A B 0.1
wire B A 0.3
gate C neg   0.5

wire A C 0.1
wire C B 0.1

For min and max gates, the arguments are:

For other gate types, the number of permitted inputs is 1 and therefore this field is never given in the input file.

For wires, the arguments are:

As in MP2, your program must tolerate and report errors in the input. Your program must operate exactly as the program did for MP2, giving error messages and producing, as output, a copy of the input as reconstructed from the internal data structure.

The emphasis in this assignment is that your program must use the Java class hierarchy to support the different gate types. Note that use of the class hierarchy is likely to force you to convert the constructors in your classes to factory methods.

Grading criteria: No credit will be given to programs that do not represent a substantial attempt at meeting the requirements of this assignment. As in MP2, your program must:

In addition, your program must:

Note: 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.

Note: If you are pressed for time, do not bother supporting isfalse or isunknown. We understand that if you can do istrue you can figure out the other two.

Note: You are free to use any solution to MP2 as a starting point for your solution to MP3 so long as the @author comment correctly attributes the authorship of the source and so long as additional comments at the top show where you got the source.

Submission: Your solution should consist of a single file, with one public method, main. (Later, we will chop the file into smaller more managable pieces, as it grows.)

To submit your solution, make sure it is in a file called TernaryLogic.java (this requires that the main method be in a class called TernaryLogic. This must be in the current directory. Then, follow the same dialogue with the Linux shell you used for MP1, except that you will use mp3 wherever the instructions said to use mp1.