eccezioni

This commit is contained in:
orange 2016-12-30 15:23:40 +01:00
parent f211d00400
commit 43210eb5ee
5 changed files with 23 additions and 5 deletions

View File

@ -24,7 +24,13 @@ public class Libro extends Opera{
if(!sc.hasNextLine()) return null; if(!sc.hasNextLine()) return null;
titolo=sc.nextLine(); titolo=sc.nextLine();
if(!sc.hasNextLine()) return null; if(!sc.hasNextLine()) return null;
anno=Integer.parseInt(sc.nextLine()); try{
anno=Integer.parseInt(sc.nextLine());
}
catch(NumberFormatException exception){
System.err.println("Anno non inserito correttamente.\nAnno impostato a zero");
anno=0;
}
if(!sc.hasNextLine()) return null; if(!sc.hasNextLine()) return null;
pos=sc.nextLine(); pos=sc.nextLine();
if(!sc.hasNextLine()) return null; if(!sc.hasNextLine()) return null;

View File

@ -31,7 +31,13 @@ public class OperaMult extends Opera{
if(!sc.hasNextLine()) return null; if(!sc.hasNextLine()) return null;
supporto=sc.nextLine(); supporto=sc.nextLine();
if(!sc.hasNextLine()) return null; if(!sc.hasNextLine()) return null;
anno=Integer.parseInt(sc.nextLine()); try{
anno=Integer.parseInt(sc.nextLine());
}
catch(NumberFormatException exception){
System.err.println("Anno non inserito correttamente.\nAnno impostato a zero");
anno=0;
}
if(!sc.hasNextLine()) return null; if(!sc.hasNextLine()) return null;
pos=sc.nextLine(); pos=sc.nextLine();
if(!sc.hasNextLine()) return null; if(!sc.hasNextLine()) return null;

View File

@ -7,7 +7,7 @@ CD
Autore1 Autore1
Titolo7 Titolo7
USB USB
1996 1996a
4S 4S
# #
Autore5 Autore5

View File

@ -31,7 +31,13 @@ public class Stampa extends Opera{
if(!sc.hasNextLine()) return null; if(!sc.hasNextLine()) return null;
tecnica=sc.nextLine(); tecnica=sc.nextLine();
if(!sc.hasNextLine()) return null; if(!sc.hasNextLine()) return null;
anno=Integer.parseInt(sc.nextLine()); try{
anno=Integer.parseInt(sc.nextLine());
}
catch(NumberFormatException exception){
System.err.println("Anno non inserito correttamente.\nAnno impostato a zero");
anno=0;
}
if(!sc.hasNextLine()) return null; if(!sc.hasNextLine()) return null;
pos=sc.nextLine(); pos=sc.nextLine();
if(!sc.hasNextLine()) return null; if(!sc.hasNextLine()) return null;

View File

@ -1,7 +1,7 @@
Autore1 Autore1
Titolo1 Titolo1
Pergamena Pergamena
2000 2000f
4D 4D
# #
Autore2 Autore2