コード例 #1
0
  private void levelsCsv(Tournament tournament) {
    File levelsCSV = new File(names[2]);

    if (levelsCSV.isFile() && levelsCSV.canRead()) {
      levelsCSV.delete();
    }

    try {
      levelsCSV.createNewFile();

      FileWriter fw = new FileWriter(levelsCSV.getAbsoluteFile());
      BufferedWriter bw = new BufferedWriter(fw);

      for (Level level : tournament.getLevelMap().values()) {
        bw.write("levelId;" + level.getLevelId() + separator);
        bw.write("levelName;" + level.getLevelName() + separator);
        bw.write("levelNr;" + level.getLevelNr() + separator);
        bw.write("nofWinners;" + level.getNofWinners() + separator);
        bw.write("startTime;" + Utils.dateToStringFull(level.getStartTime()) + separator);
        bw.write(separator);
        for (Round round : level.getRoundMap().values()) {
          Map<Broker, double[]> resultMap = round.determineWinner();
          singleRound(bw, ";", round, resultMap);
          bw.write(separator);
        }
      }

      bw.close();

      copyFile(levelsCSV, names[3]);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
  private void tournamentCsv(Tournament tournament) {
    File tournamentCSV = new File(names[0]);

    if (tournamentCSV.isFile() && tournamentCSV.canRead()) {
      tournamentCSV.delete();
    }

    // Create new CSVs
    try {
      tournamentCSV.createNewFile();

      FileWriter fw = new FileWriter(tournamentCSV.getAbsoluteFile());
      BufferedWriter bw = new BufferedWriter(fw);

      bw.write("tournamentId;" + tournament.getTournamentId() + separator);
      bw.write("tournamentName;" + tournament.getTournamentName() + separator);
      bw.write("status;" + tournament.getState() + separator);
      bw.write("pomId;" + tournament.getPomId() + separator);
      bw.write("MaxAgents;" + tournament.getMaxAgents() + separator);

      bw.write(separator);

      bw.write("levelId;levelName;levelNr;nofRounds;nofWinners;startTime" + separator);
      for (Level level : tournament.getLevelMap().values()) {
        bw.write(
            String.format(
                "%s;%s;%s;%s;%s;%s%s",
                level.getLevelId(),
                level.getLevelName(),
                level.getLevelNr(),
                level.getNofRounds(),
                level.getNofWinners(),
                Utils.dateToStringFull(level.getStartTime()),
                separator));
      }

      bw.close();

      copyFile(tournamentCSV, names[1]);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }