29.7.13

Also a Java utility library that includes a more RSI-friendly print option

 // utility functions  
 public class S {  
      private static boolean DEBUGMODE = true;  
      private S(){}  
      public static void p(Object s)  
      {  
           if (DEBUGMODE)  
           {  
                StackTraceElement[] ste = Thread.currentThread().getStackTrace();  
                String n = ste[2].getClassName();  
                System.out.println(n +": "+ s.toString());  
           }  
      }  
      public static Position int2Position(int i)  
      {  
           switch (i)  
           {  
           case 5: return Position.SCANNER;  
           case 0: return Position.ONE;  
           case 1: return Position.TWO;  
           case 2: return Position.THREE;  
           case 3: return Position.FOUR;  
           case 4: return Position.FIVE;  
           default: return null;  
           }  
      }  
      public static int Position2int(Position p)  
      {  
           if (p==Position.SCANNER)  return 5;  
           else if (p==Position.ONE)  return 0;  
           else if (p==Position.TWO)  return 1;  
           else if (p==Position.THREE) return 2;  
           else if (p==Position.FOUR) return 3;  
           else if (p==Position.FIVE) return 4;  
           return -1; // this should never happen; if it does, hopefully this causes some kind of silly error  
      }  
 }  

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home