示例#1
0
 /**
  * Prints specified record.
  *
  * @param rNbr record ID
  */
 private static void printRecord(String rNbr) {
   for (Record r : records) {
     if (r.getId() == Long.parseLong(rNbr) && r != null) {
       System.out.println(r.getMedicalData());
     }
   }
 }
示例#2
0
  /**
   * Sets client command line in an editing state and submits data to server unless it is
   * interrupted by the user.
   *
   * @param rNbr
   * @throws IOException
   */
  private static void editRecord(String rNbr) throws IOException {
    Record record = null;
    boolean isDone = false;

    for (Record r : records) {
      if (r.getId() == Long.parseLong(rNbr)) {
        record = r;
      }
    }

    while (!isDone) {
      System.out.println("OLD: " + record.getMedicalData());
      System.out.print("NEW: ");
      msg = read.readLine();
      System.out.println("Save change? <yes>/<no>");
      String ans = read.readLine();

      if (ans.equalsIgnoreCase("yes")) {
        out.println(msg);
        out.flush();
        isDone = true;
        System.out.println("Successfully edited record.");
      }
    }
  }