Пример #1
0
  /** Performs and verifies transactions */
  private void processTransactions() {
    List<String> trans;

    while (true) {
      trans = data.getTransaction();
      if (trans == null) {
        files.writeAccounts(data.getAccounts());
        break;
      } else if (trans.get(0).substring(0, 5).equals("ERROR")) {
        System.out.println(trans.get(0));
        break;
      }

      int transType = Integer.parseInt(trans.get(0).substring(0, 2));
      String error = "";

      switch (transType) {
        case 0:
          break;
        case 1:
          error = data.withdraw(trans.get(0));
          break;
        case 2:
          error = data.withdraw(trans.get(0));
          if (error != null) {
            System.out.println(error);
          }
          error = data.deposit(trans.get(1));
          break;
        case 3:
          error = data.withdraw(trans.get(0));
          break;
        case 4:
          error = data.deposit(trans.get(0));
          break;
        case 5:
          error = data.create(trans.get(0));
          break;
        case 6:
          error = data.delete(trans.get(0));
          break;
        case 7:
          error = data.enable(trans.get(0), true);
          break;
        case 8:
          error = data.changeplan(trans.get(0));
          break;
        case 9:
          error = data.enable(trans.get(0), false);
          break;
        case 10:
          break;
      }
      if (error != null) {
        System.out.println(error);
      }
    }
  }
Пример #2
0
 /**
  * @param backFiles object
  *     <p>Assigns objects provided to local copies for use by backEnd Calls files to load input
  *     data and passes this to the data object
  */
 public backEnd(backFiles files) {
   this.files = files;
   data = new backData(files.loadAccounts(), files.loadTransactions());
 }