private static void ModifyWorks() throws ClassNotFoundException, SQLException { Scanner input = new Scanner(System.in); String option = new String(); String var = new String(); String val = new String(); System.out.println("Modification of works"); System.out.println("What is the work you which to modify"); ArrayList<Work> selection = SelectWorks(); System.out.println("The works you wish to modify are the following"); DisplayWorks(selection); System.out.println(""); System.out.println("What is the variable you which to modify?"); System.out.println( "For the ID, enter 'I'. For the author ID, enter 'A'. For the title, enter 'T'. " + "For the date of first publication, enter 'P'. For the original language, enter 'L'"); option = input.nextLine(); switch (option) { case "I": var = "workid"; break; case "A": var = "authorid"; break; case "T": var = "title"; break; case "P": var = "first_publication"; break; case "L": var = "original_language"; break; default: System.out.println("The value entered is not valid, please enter a correct one"); } System.out.println(""); System.out.println("What is the new value of this variable? "); val = input.nextLine(); if (var.equals("authorid")) { while (libraryDAO.getAuthorFromQuery("authorid", val).isEmpty()) { System.out.println("This ID doesn't exist, please enter a valid ID"); val = input.nextLine(); } } libraryDAO.modifyWorkInQuery(selection, var, val); }