GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Java/usacotools.java at d8c9671d8d923b63f24b28de6d5519e3956bff9c · javaarchive/Java
This repository was archived by the owner on Feb 29, 2024. It is now read-only.
Expand file tree/ Copy pathusacotools.javaMore file actions 211 lines (193 loc) · 4.91 KB / Copy pathusacotools.javaFile metadata and controls211 lines (193 loc) · 4.91 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 import java.util.*; import java.io.*; public abstract class usacotools { public static int classify(char x,char off,char on) { /* * Method to classify X is off value or on value * Returns -1 if neither * */ if (x==off){ return 0; }else if(x==on) { return 1; }else { return -1; } } public static int ERROR=1; public static String error="Error"; public static int[][] morph(int[][] map,int a,int b){ for(int i=0;i<map.length;i++) { for(int j=0;j<map[i].length;j++) { if(map[i][j]==a) { map[i][j]=b; } } } return map; } public static boolean isrect(int[][] map,int x,int y) { int cachedsize=-1; int cachey=-1; for(int i=x;i<map.length;i++) { if(x>cachedsize) { return false; } for(int j=y;j<map.length;j++) { if(map[x][y]==0) { cachey=y; cachedsize=x; } if(y>cachey) { return false; } } } return true; } public static ArrayList<Integer> touching(int[][] map,int x,int y){ ArrayList<Integer> out=new ArrayList<Integer>(); try { out.add(map[x-1][y]); }catch(Exception e) { } try { out.add(map[x+1][y]); }catch(Exception e) { } try { out.add(map[x][y-1]); }catch(Exception e) { } try { out.add(map[x][y+1]); }catch(Exception e) { } return out; } public static String repeat(int count, String with) { return new String(new char[count]).replace("\0", with); } public static String changen(int position, char ch, String str){ char[] charArray = str.toCharArray(); charArray[position] = ch; return new String(charArray); } public static BufferedReader mreader(String filen) throws IOException { return new BufferedReader(new FileReader(filen)); } public static PrintWriter mwriter(String filen) throws IOException { return new PrintWriter(new BufferedWriter(new FileWriter(filen))); } public static Scanner getsysscan() { return new Scanner(System.in); } public static int binarySearch(int arr[], int l, int r, int x) { /* * Binary Search * */ if (r>=l) { int mid = l + (r - l)/2; if (arr[mid] == x) return mid; if (arr[mid] > x) return binarySearch(arr, l, mid-1, x); return binarySearch(arr, mid+1, r, x); } return -1; } public static int ebs(int arr[], int l, int r, int x) { Arrays.sort(arr); return binarySearch(arr, l, r, x); } public static int lsearch(int[] a,int b) { for(int i=0;i<a.length;i++) { if(a[i]==b) { return i; } } return -1; } public static void print(String out) { System.out.print(out+"\n"); } public static void printf(String out) { System.out.print(out+"\n"); } public static void print(String out,String end) { System.out.print(out+end); } public static void print(String out,boolean flush) { System.out.print(out+"\n"); if(flush) { System.out.flush(); } } public static int[] toArray(ArrayList<Integer> arr) { int[] stuff=new int[arr.size()]; for(int i=0;i<arr.size();i++) { stuff[i]=arr.get(i); } return stuff; } public static long[] toArrayl(ArrayList<Long> arr) { long[] stuff=new long[arr.size()]; for(int i=0;i<arr.size();i++) { stuff[i]=arr.get(i); } return stuff; } public static String[] toArrays(ArrayList<String> arr) { String[] stuff=new String[arr.size()]; for(int i=0;i<arr.size();i++) { stuff[i]=arr.get(i); } return stuff; } public static Set<String> sclones(Set<String> k) { return (new HashSet<String>(k)); } public static Set<Integer> sclone(Set<Integer> k) { return (new HashSet<Integer>(k)); } public static Set<Long> sclonel(Set<Long> k) { return (new HashSet<Long>(k)); } public static boolean smartequals(int[] a,int[] b) { if(a.length!=b.length) { return false; } for(int i=0;i<a.length;i++) { if(a[i]!=b[i]) { return false; } } return true; } public static boolean smartequals2D(int[][] a,int[][] b) { if(a.length!=b.length) { return false; } for(int i=0;i<a.length;i++) { if(smartequals(a[i],b[i])) { return false; } } return true; } public static void main(String[] args) throws Exception{ System.out.println("Running demo"); Scanner sc=getsysscan(); print("Welcome to the demo\nYou have many choices \n 1} Run help \n2} Check for a update \n3}Run demo to see features\n By the way the newest features are always at the bottom!!!!!"); print(">",""); try { int val=sc.nextInt(); }catch(Exception e) { print("Oops that did not go well please rerun and choose a INTEGER"); } } } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |