|
TruthTableQuiz
Connectives.java
//----------------------------------------------------------------------
public class Connectives {
public static final char OR='\u2228';
public static final char AND='\u2227';
public static final char XOR='\u2295';
public static final char NEGATION='\u00ac';
public static final char CONDITIONAL='\u2192';
public static final char BICONDITIONAL='\u2194';
public static final char A_OR='|';
public static final char A_AND='&';
public static final char A_XOR='^';
public static final char A_NEGATION='!';
public static final char A_CONDITIONAL='?';
public static final char A_BICONDITIONAL='~';
//----------------------------------------------------------------------
public static char toASCII(char C) {
if(isAND(C))
return A_AND;
else if(isOR(C))
return A_OR;
else if(isXOR(C))
return A_XOR;
else if(isNEGATION(C))
return A_NEGATION;
else if(isCONDITIONAL(C))
return A_CONDITIONAL;
else if(isBICONDITIONAL(C))
return A_BICONDITIONAL;
else
return C;
}
public static char toUnicode(char C) {
if(isAND(C))
return AND;
else if(isOR(C))
return OR;
else if(isXOR(C))
return XOR;
else if(isNEGATION(C))
return NEGATION;
else if(isCONDITIONAL(C))
return CONDITIONAL;
else if(isBICONDITIONAL(C))
return BICONDITIONAL;
else
return C;
}
public static String toUnicode(String S) {
String N=new String();
for(int i=0;i<S.length();i++)
N=N+toUnicode(S.charAt(i));
return N;
}
public static String toASCII(String S) {
String N=new String();
for(int i=0;i<S.length();i++)
N=N+toASCII(S.charAt(i));
return N;
}
//----------------------------------------------------------------------
/**
* Determine whether or not a given character is a logical connective.
*
* @param C the input character to test
* @return true if C is a logical connective, false otherwise.
*
*/
public static boolean isConnective(char C) {
if(isAND(C) || isOR(C) || isXOR(C) || isNEGATION(C) ||
isCONDITIONAL(C) || isBICONDITIONAL(C) )
return true;
else
return false;
}
public static boolean isAND(char C) {
if(C==AND || C==A_AND ) return true;
else return false;
}
public static boolean isOR(char C) {
if(C==OR || C==A_OR ) return true;
else return false;
}
public static boolean isNEGATION(char C) {
if(C==NEGATION || C==A_NEGATION ) return true;
else return false;
}
public static boolean isXOR(char C) {
if(C==XOR || C==A_XOR ) return true;
else return false;
}
public static boolean isCONDITIONAL(char C) {
if(C==CONDITIONAL || C==A_CONDITIONAL )
return true;
else return false;
}
public static boolean isBICONDITIONAL(char C) {
if(C==BICONDITIONAL || C==A_BICONDITIONAL )
return true;
else return false;
}
}
//----------------------------------------------------------------------
|