//Christian Tirella //Brian Sweeney //CSU670 Project import java.util.*; //Container class for the product of TruthTable.getRelationTable() public class RelationTable { ArrayList relationTable; int tableIndex; public RelationTable (ArrayList relationTable) { this.relationTable = new ArrayList(); tableIndex = 0; } public void add(TruthRow truthTableRow) { relationTable.add(truthTableRow); } //set index to zero public void start () {tableIndex = 0;} //return true if there are more items in table and move index ahead one, return false otherwise public boolean next () { if (tableIndex < relationTable.size() - 1){ tableIndex++; return true; } else return false; } public TruthRow getCurrentRow() { Object returnable = relationTable.get(tableIndex); return (TruthRow)returnable; } //returns the indices of the columns that can be forced //in other words of the columns that contain the same value: // 0 0 0 // 0 1 0 // 0 1 1 //in the above relationtable column 1 or index 0 would be returned public ArrayList forcableColumnIndex () { ArrayList result = new ArrayList (2); boolean stillMatching = false; for (int columnIndex = 0; columnIndex <= 3; columnIndex++) { ArrayList hold = new ArrayList(); for (int tableIndex = 0; tableIndex <= (relationTable.size() - 1); tableIndex++) { //build a list of items on the current column TruthRow temp = relationTable.get(columnIndex); Integer integer = temp.bitAt(tableIndex); hold.add(integer); } //check to see if the column contains only 1s or only 0s int currentIndex = 0; int nextIndex = 1; for ( ; currentIndex < hold.size() - 2; currentIndex++) { if (hold.get(currentIndex).equals(hold.get(nextIndex))) { stillMatching = true; } else stillMatching = false; } if (stillMatching == true) { result.add(columnIndex); } } return result; } }