/** @author Scott Marshall @author University of Glasgow, MSc IT Project 2001 @author Building an OnLine Course in Computing Fundamentals */ package ukacgla_2inputKMap; import ukacgla_KMap.*; import java.util.*; class Minterm extends Abstract_Minterm { public Minterm(String b, int rows, int cols){ super(b, rows, cols); } /** Begin reading dataMap for specific sequences. If sequence is met, append chars to answer, and reset data in table Finally, make this instance of minterm a copy of answer. */ public void simplify(){ StringBuffer answer = new StringBuffer(); //check for !x for complete rows if (dataMap[0][0] == 1 && dataMap[0][1] ==1) { answer.append("!x +"); dataMap[0][0] = 0; dataMap[0][1] = 0; } //check for x for complete row if (dataMap[1][0] == 1 && dataMap[1][1] ==1) { answer.append("x +"); dataMap[1][0] = 0; dataMap[1][1] = 0; } //check for first column if (dataMap[0][0] ==1 && dataMap[1][0] ==1) { answer.append("!y +"); dataMap[0][0] = 0; dataMap[1][0] = 0; } //check for second column. if (dataMap[0][1] == 1 && dataMap[1][1] ==1) { answer.append("y +"); dataMap[0][1] = 0; dataMap[1][1] = 0; } //then begin looking for ones ! if (dataMap[0][0]==1) answer.append("!x!y +"); if (dataMap[0][1]==1) answer.append("!xy +"); if (dataMap[1][0]==1) answer.append("x!y +"); if (dataMap[1][1]==1) answer.append("xy +"); //delete excess +'s. int length = answer.length(); if (answer.charAt(length-1)=='+') answer.deleteCharAt(length-1); //make this instance of minterm a copy of answer. this.minterm = answer; }//ends simplify() }