/* * Copyright (c) 2003,2004 Aly Merchant * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from the * use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * * 2. Altered source versions must be plainly marked as such, and must not * be misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source * distribution. */ package tenk; import java.util.*; import java.io.*; public class Summary { public static final String ALL = "All Runners"; public static final String[] GEN = {"All Male Runners","All Female Runners"}; public static final String[] CAT = {"Male Runners 0-19","Female Runners 0-19", "Male Runners 20-29","Female Runners 20-29", "Male Runners 30-34","Female Runners 30-34", "Male Runners 35-39","Female Runners 35-39", "Male Runners 40-44","Female Runners 40-44", "Male Runners 45-49","Female Runners 45-49", "Male Runners 50-59","Female Runners 50-59", "Male Runners 60+ ","Female Runners 60+ "}; private Object[] runners; private ArrayList[] gens = {new ArrayList(), new ArrayList()}; private ArrayList[] cats = new ArrayList[CAT.length]; class RunnerSort implements Comparator { public int compare(Object a, Object b) { if (a instanceof MainRun && b instanceof MainRun) return ((MainRun)a).getITime().compareTo( ((MainRun)b).getITime() ); return 0; } } public static int categorize(MainRun mr) { if (mr.age < 2) return -1; if (mr.gender != 'M' && mr.gender != 'F') return -1; int result = (mr.gender == 'M') ? 0 : 1; if (mr.age > 19) result += 2; if (mr.age > 29) result += 2; if (mr.age > 34) result += 2; if (mr.age > 39) result += 2; if (mr.age > 44) result += 2; if (mr.age > 49) result += 2; if (mr.age > 59) result += 2; return result; } public Summary(Object[] r) { this.runners = r; for (int i=0;i -1 && cats[c].size() < 3) { if (gens[c % 2].size() < 3) gens[c % 2].add(r[i]); else cats[c].add(r[i]); } } } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("\n\n"+ALL); for (int i=0; i"+rank+""+mr.getFullName()+"" + ""+mr.bib+""+mr.getSTime()+""; } public void catToHTML(String filename) { FileWriter fw; try { fw = new FileWriter(filename); fw.write("\n\t\n\t\n"); for (int j=0; j<2; j++) { fw.write("\t\t

"+GEN[j]+"

\n"); fw.write("\t\t\n"); fw.write("\t\t\t\n"); for (int i=0; i\n"); } for (int j=0; j"+CAT[j]+"\n"); fw.write("\t\t
RankNameBibTime
\n"); fw.write("\t\t\t\n"); for (int i=0; i\n"); } fw.write("\t\n"); fw.close(); } catch (IOException ioe) { System.out.println("Problem during generation, terminating early"); } } public void allToHTML(String filename) { FileWriter fw; try { fw = new FileWriter(filename); fw.write("\n\t\n\t\n"); fw.write("\t\t

"+ALL+"

\n"); fw.write("\t\t
RankNameBibTime
\n"); fw.write("\t\t\t\n"); for (int i=0; i\n\t\n"); fw.close(); } catch (IOException ioe) { System.out.println("Problem during generation, terminating early"); } } }
RankNameBibTime