//----------------------------------------------------------------- // CSE 461 Project // // debug.java: an interface for selective debug messages //----------------------------------------------------------------- //----------------------------------------------------------------- // Debug: the debugging output interface. This class is like // System in that it is static. Use print and println // for messages, Enable and Disable turn specific // categories on and off. //----------------------------------------------------------------- class Debug { private static String enabled = ""; public static void Enable (char type) { if (!IsEnabled (type)) enabled = enabled + type; } public static void Disable (char type) { int i = enabled.indexOf (type); if (i >= 0) enabled = enabled.substring (0, i) + enabled.substring (i+1); } public static void SetEnabled (String types) { enabled = types; } public static boolean IsEnabled (char type) { return (enabled.indexOf (type) >= 0); } public static void print (char type, String s) { if (IsEnabled (type)) System.out.print (s); } public static void println (char type, String s) { if (IsEnabled (type)) System.out.println (s); } }