Exemple #1
0
    public Master() throws IOException {
      try {
        readFileToString("commands.txt");
      } catch (IOException e) {
        throw new IOException();
      }

      try {
        readFileToString("wanted.txt");
      } catch (IOException e) {
        throw new IOException();
      }

      ArrayList officesData;
      try {
        officesData = stringTokenizer(readFileToString("offices.txt"));
      } catch (IOException e) {
        throw new IOException();
      }
      currentDay = 0;
      inTransit = new ArrayList();
      newCriminals = new ArrayList();
      offices = new ArrayList();

      overwriteFile("", "log_master.txt");
      overwriteFile("", "log_front.txt");

      for (int i = 1; i < officesData.size(); ) {
        String officeName = (String) officesData.get(i);
        int transmiTime = (new BigDecimal((String) officesData.get(i + 1))).intValue();
        int requiredPostage = (new BigDecimal((String) officesData.get(i + 2))).intValue();
        int maxCap = (new BigDecimal((String) officesData.get(i + 3))).intValue();
        int persuationAmmount = (new BigDecimal((String) officesData.get(i + 4))).intValue();
        int maxPackageLen = (new BigDecimal((String) officesData.get(i + 5))).intValue();

        Office newOffice = new Office();
        newOffice.name = officeName;
        newOffice.transitTime = transmiTime;
        newOffice.postagePrice = requiredPostage;
        newOffice.maxCap = maxCap;
        newOffice.persuationPrice = persuationAmmount;
        newOffice.maxPackageSize = maxPackageLen;

        offices.add(newOffice);
        overwriteFile("", "log_" + officeName + ".txt");

        i = i + 6;
      }
    }