Ejemplo n.º 1
0
  private void nameLengthStatistics() {
    Iterator i = Person.iterator();
    Person p;
    int l = Person.getMaxNameLength();
    int lengthTable[] = new int[l + 1];
    int j;

    System.out.println();
    // System.out.println("Name length: Number of persons");
    while (i.hasNext()) {
      p = (Person) i.next();
      lengthTable[p.getName().length()]++;
    }
    for (j = 1; j <= l; j++) {
      System.out.print(j + ": " + lengthTable[j] + "  ");
      if (j % 5 == 0) System.out.println();
    }
    System.out.println();
  }
Ejemplo n.º 2
0
  private void publicationCountStatistics() {
    Iterator i = Person.iterator();
    Person p;
    int l = Person.getMaxPublCount();
    int countTable[] = new int[l + 1];
    int j, n;

    System.out.println();
    System.out.println("Number of publications: Number of persons");
    while (i.hasNext()) {
      p = (Person) i.next();
      countTable[p.getCount()]++;
    }
    n = 0;
    for (j = 1; j <= l; j++) {
      if (countTable[j] == 0) continue;
      n++;
      System.out.print(j + ": " + countTable[j] + "  ");
      if (n % 5 == 0) System.out.println();
    }
    System.out.println();
  }