Exemple #1
0
 public static void DisplayWorks(ArrayList<Work> selection) {
   System.out.println("Work ID ; Author ID ; Title ; First Publication ; Original Language");
   for (Work w : selection) {
     w.toDisplay();
   }
   System.out.println("");
 }
Exemple #2
0
  private static void AddWorks() throws ClassNotFoundException, SQLException {
    Scanner input = new Scanner(System.in);
    String val = new String();
    String opt = new String();
    System.out.println("Addition of works");
    Work a = new Work();
    System.out.println("Please enter the ID of the new work");
    val = input.nextLine();
    while (!libraryDAO.getWorkFromQuery("workid", val).isEmpty()) {
      System.out.println("This ID is already used, please enter a valid ID");
      val = input.nextLine();
    }
    a.setWorkid(val);
    System.out.println("Is the author of this work a new author? (Y/N)");
    opt = input.nextLine();
    if (opt.equals("Y")) {
      ManageAuthors.AddAuthors();
    }
    System.out.println(" ");
    System.out.println("Please enter the ID of the author of the work");
    val = input.nextLine();
    while (libraryDAO.getAuthorFromQuery("authorid", val).isEmpty()) {
      System.out.println("This ID doesn't exist, please enter a valid ID");
      val = input.nextLine();
    }
    a.setAuthorid(val);

    System.out.println("");
    System.out.println("Please enter the title of the work");
    a.setTitle(input.nextLine());
    System.out.println("");
    System.out.println("Please enter the date of first publication of the work");
    a.setFirstPublication(input.nextLine());
    System.out.println("");
    System.out.println("Please enter the original language of the work");
    a.setOrigLanguage(input.nextLine());
    System.out.println("");
    System.out.println("The new work is:");
    a.toDisplay();
    libraryDAO.setWorkToQuery(a);
  }