1
1
import java .util .*;
2
2
import java .io .*;
3
3
public abstract class usacotools {
4
- public static int classify (char x ,char off ,char on ) {
5
- /*
6
- * Method to classify X is off value or on value
7
- * Returns -1 if neither
8
- *
9
- */
10
- if (x ==off ){
11
- return 0 ;
12
- }else if (x ==on ) {
13
- return 1 ;
14
- }else {
15
- return -1 ;
16
- }
17
-
18
- }
19
- public static int ERROR =1 ;
4
+ public static final String ANSI_RESET = "\u001B [0m" ;
5
+ public static final String ANSI_BLACK = "\u001B [30m" ;
6
+ public static final String ANSI_RED = "\u001B [31m" ;
7
+ public static final String ANSI_GREEN = "\u001B [32m" ;
8
+ public static final String ANSI_YELLOW = "\u001B [33m" ;
9
+ public static final String ANSI_BLUE = "\u001B [34m" ;
10
+ public static final String ANSI_PURPLE = "\u001B [35m" ;
11
+ public static final String ANSI_CYAN = "\u001B [36m" ;
12
+ public static final String ANSI_WHITE = "\u001B [37m" ;
13
+ public static int ERRORS =0 ;
14
+ public static ArrayList <Exception > console =new ArrayList <Exception >();
20
15
public static String error ="Error" ;
21
- public static int [][] morph (int [][] map ,int a ,int b ){
22
- for (int i =0 ;i <map .length ;i ++) {
23
- for (int j =0 ;j <map [i ].length ;j ++) {
24
- if (map [i ][j ]==a ) {
25
- map [i ][j ]=b ;
26
- }
27
- }
28
- }
29
- return map ;
30
- }
16
+ public static int debugcode =-1 ;
31
17
public static boolean isrect (int [][] map ,int x ,int y ) {
32
18
int cachedsize =-1 ;
33
19
int cachey =-1 ;
@@ -47,6 +33,10 @@ public static boolean isrect(int[][] map,int x,int y) {
47
33
}
48
34
return true ;
49
35
}
36
+ public static void report (Exception e ) {
37
+ console .add (e );
38
+ ERRORS ++;
39
+ }
50
40
public static ArrayList <Integer > touching (int [][] map ,int x ,int y ){
51
41
ArrayList <Integer > out =new ArrayList <Integer >();
52
42
try {
@@ -146,14 +136,6 @@ public static int[] toArray(ArrayList<Integer> arr) {
146
136
}
147
137
return stuff ;
148
138
149
- }
150
- public static long [] toArrayl (ArrayList <Long > arr ) {
151
- long [] stuff =new long [arr .size ()];
152
- for (int i =0 ;i <arr .size ();i ++) {
153
- stuff [i ]=arr .get (i );
154
- }
155
- return stuff ;
156
-
157
139
}
158
140
public static String [] toArrays (ArrayList <String > arr ) {
159
141
String [] stuff =new String [arr .size ()];
@@ -162,50 +144,65 @@ public static String[] toArrays(ArrayList<String> arr) {
162
144
}
163
145
return stuff ;
164
146
}
165
- public static Set <String > sclones (Set <String > k ) {
166
- return (new HashSet <String >(k ));
167
- }
168
- public static Set <Integer > sclone (Set <Integer > k ) {
169
-
170
- return (new HashSet <Integer >(k ));
171
- }
172
- public static Set <Long > sclonel (Set <Long > k ) {
173
- return (new HashSet <Long >(k ));
174
- }
175
- public static boolean smartequals (int [] a ,int [] b ) {
176
- if (a .length !=b .length ) {
177
- return false ;
178
- }
179
- for (int i =0 ;i <a .length ;i ++) {
180
- if (a [i ]!=b [i ]) {
181
- return false ;
182
- }
183
- }
184
- return true ;
185
- }
186
- public static boolean smartequals2D (int [][] a ,int [][] b ) {
187
- if (a .length !=b .length ) {
188
- return false ;
189
- }
190
- for (int i =0 ;i <a .length ;i ++) {
191
- if (!(smartequals (a [i ],b [i ]))) {
192
- return false ;
193
- }
147
+ public static void exit () {
148
+ System .exit (1 );
149
+ }
150
+ public static void exit (int code ) {
151
+ System .exit (code );
152
+ }
153
+ public static long benchmark () {
154
+ return System .currentTimeMillis ();
155
+
156
+ }
157
+ public static long benchmark2 () {
158
+ return System .nanoTime ();
159
+ }
160
+ public static void clear (){
161
+ //Clears Screen in java
162
+ try {
163
+ if (System .getProperty ("os.name" ).contains ("Windows" ))
164
+ new ProcessBuilder ("cmd" , "/c" , "cls" ).inheritIO ().start ().waitFor ();
165
+ else
166
+ Runtime .getRuntime ().exec ("clear" );
167
+ } catch (Exception e ) {report (e );}
168
+ }
169
+ public static void console () {
170
+ System .out .println ("Total Errors: " +ERRORS );
171
+ for (Exception a :console ) {
172
+ if (ESTACK ) {
173
+ print (a .getStackTrace ().toString ());
174
+
175
+ }
176
+ if (EMSG ){print (a .toString ());print (a .getMessage ());print (a .getLocalizedMessage ());}
177
+
178
+ }
179
+ }
180
+ public static void run (String exe ){
181
+ try {Process process = Runtime .getRuntime ().exec (exe );}catch (Exception e ) {
182
+ report (e );
194
183
}
195
- return true ;
196
184
}
185
+ public static boolean ESTACK =true ;
186
+ public static boolean EMSG =true ;
187
+
197
188
public static void main (String [] args ) throws Exception {
198
189
System .out .println ("Running demo" );
199
190
Scanner sc =getsysscan ();
200
- print ("Welcome to the demo\n You have many choices \n 1 } Run help \n 2} Check for a update \n 3}Run demo to see features\n By the way the newest features are always at the bottom!!!!! " );
191
+ print ("Welcome to the demo\n You have many choices \n 1 } Run help \n 2} Check for a update \n 3}Run demo to see features" );
201
192
print (">" ,"" );
193
+ int val ;
202
194
try {
203
- int val =sc .nextInt ();
195
+ val =sc .nextInt ();
204
196
}catch (Exception e ) {
205
197
print ("Oops that did not go well please rerun and choose a INTEGER" );
198
+ val =-1 ;
199
+ report (e );
200
+ print ("How about we test erro reporting" );
201
+ console ();
202
+ }
203
+ if (1 ==val ) {
206
204
207
205
}
208
206
}
209
-
210
207
211
208
}
0 commit comments