import java.util.*; /** * Write a description of class Print here. * * @author (your name) * @version (a version number or a date) */ public class Interface { public Interface() { } public boolean propSearcher(Logic logic, String a) { boolean ret = false; for(String x : logic.getKeys()) { if(x.equals(a)) ret = true; } return ret; } public void printMethods() { System.out.println("To use the operators type 'alpha' then an operator (&, v, >, <->, ~) then type 'beta'"); System.out.println("To negate multiple propositions start by typing '~' first, then type the list of propositions."); System.out.println("To print a particular type 'alpha' then 'print'."); System.out.println("To print all type 'PRINT' then 'print'."); System.out.println("To the names of the propositions type 'EDIT' then 'change name' then type the original name then "); System.out.println(" type 'to' then type the new name. (Note: if the new name contains more than one word, the spaces"); System.out.println(" will be replaced with periods '.')"); System.out.println("To Check if a particular prop is a tautology type 'CHECK' then 'tautology' then that propositions"); System.out.println("To Check if a particular prop is a logically equivalent to another type 'CHECK' then 'logic' the "); System.out.println(" names of both propositions."); System.out.println("To Check for any tautology or logically equivalent propositions just type 'FIND' then either "); System.out.println(" 'tautology' or 'logic'."); System.out.println("To Check if an argument is valid simply type 'CHECK' then 'valid' then the propositions in the"); System.out.println(" argument with the conclusion being the last one."); System.out.println("If you want to see this message again just type 'help'."); } /** * prints p */ public void print(Logic logic) { int keys[] = new int[logic.getNumberOfPropositions()]; Set key = logic.getKeys(); String ke[] = new String[logic.getNumberOfPropositions()]; int i = 0; for(String x : key) { keys[i] = x.length(); ke[i] = x; i++; } int max = max(keys); for(int j = 0; j < logic.getNumberOfPropositions(); j++) { System.out.print(ke[j] + ": "); for(int k = max - ke[j].length(); k > 0; k--) System.out.print("-"); ArrayList temp = logic.getP(ke[j]); ArrayList val = new ArrayList(temp.size()); for(i = 0; i < temp.size(); i++) { if(temp.get(i)) val.add(temp.get(i) + " "); else val.add(temp.get(i) + ""); } System.out.print(val); System.out.println(); } } /** * used by the print methods to determine the largest key. */ private int max(int[] numbers) { int index = 0; int max = numbers[index]; while(index < numbers.length) { if(max > numbers[index]) index++; else { max = numbers[index]; index++; } } return max; } public void printSpecific(Logic logic, String a) { System.out.println(a + ": " + logic.getP(a)); } public void callMain() { String[] args = new String[0]; Main.main(args); } }