Пример #1
0
 public void inputEntry(int month, int day, int year, String golfer, int score, String course) {
   golfer temp;
   GregorianCalendar date = new GregorianCalendar(year, month - 1, day);
   if (golfers.containsKey(golfer)) {
   } else {
     golfers.put(golfer, new golfer());
   }
   temp = golfers.get(golfer);
   temp.addRun(date, score, course);
 }
Пример #2
0
  public handicap(String[] args) {
    String text;
    File file = new File(args[0]);
    File file2 = new File(args[1]);
    BufferedReader reader = null;
    Scanner s = null;
    int month;
    int day;
    int year;
    String name;
    int score;
    double diff;
    int slope;
    String course = "";
    String first;
    String p = "Course";
    String g = "Rating";
    try {

      reader = new BufferedReader(new FileReader(file));
      while ((text = reader.readLine()) != null) {
        course = "";
        s = new Scanner(text);
        month = s.nextInt();
        day = s.nextInt();
        year = s.nextInt();
        name = s.next();
        score = s.nextInt();
        while (s.hasNext()) {
          course = course + s.next();
        }
        inputEntry(month, day, year, name, score, course);
      }
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    try {
      reader = new BufferedReader(new FileReader(file2));

      while ((text = reader.readLine()) != null) {
        s = new Scanner(text);
        diff = 0.00;
        slope = 0;
        if (s.hasNext()) {
          first = s.next();
          if (first.equals(p)) {
            course = "";
            while (s.hasNext()) {
              course = course + s.next();
            }
            while (diff == 0.00) {
              text = reader.readLine();
              s = new Scanner(text);
              first = s.next();
              if (first.equals(g)) {
                diff = s.nextDouble();
                s.next();
                slope = s.nextInt();

                courses.put(course, new problem(diff, slope));
              }
            }
          }
        }
      }
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    golfer tmpGolfername;
    for (String asdf : golfers.keySet()) {
      tmpGolfername = golfers.get(asdf);
      tmpGolfername.compute();
      System.out.printf("%.2f %s%n", tmpGolfername.score, asdf);
    }
  }