Beispiel #1
0
  public static void addNewUser(String id, String name) throws Exception {
    if (id == null || name == null) return;
    id = id.trim();
    name = name.trim();
    if (id.isEmpty() || name.isEmpty() || id.contains(" ")) {
      printError(
          "Incorect ID or Name. User ID and name cannot be empty and ID cannot contain whitespace.");
      return;
    }
    boolean added = false;

    added = control.addUser(id, name);
    if (added) System.out.println("created user " + id + " with name " + name);
    else {
      User temp = control.login(id);
      System.out.println("user " + id + " already exists with name " + temp.getFullName());
      control.logout();
    }
  }