Ejemplo n.º 1
0
  private void Addgenre() throws Exception {
    boolean exit_Add = false;

    String name;

    Map<Integer, String> m = as.listGenre2();
    do {

      System.out.println("Enter the Genre Name:");

      name = sc.nextLine();

      if (!m.containsValue(name)) {
        Genre g = new Genre();
        g.setGenreName(name);
        try {
          as.createGenre(g);
          System.out.println("Added successfully");
          System.out.println("---------------------------------------------");
          exit_Add = true;
        } catch (Exception e) {
          System.out.println(e.getMessage());
        }
      } else {
        System.out.println("This Genre already exists.");
      }

      if (!exit_Add) {
        System.out.println();
        System.out.println();
        System.out.println("Press ' q '  to return or any other key to continue");
        String option = (sc.nextLine());
        if (option.length() > 0) {
          switch (option.charAt(0)) {
            case 'q':
              exit_Add = true;
              break;

            default:
              exit_Add = false;
              break;
          }
        }
      }

    } while (!exit_Add);
  }