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;
titolo=sc.nextLine();
if(!sc.hasNextLine()) return null;
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;
pos=sc.nextLine();
if(!sc.hasNextLine()) return null;

View File

@ -31,7 +31,13 @@ public class OperaMult extends Opera{
if(!sc.hasNextLine()) return null;
supporto=sc.nextLine();
if(!sc.hasNextLine()) return null;
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;
pos=sc.nextLine();
if(!sc.hasNextLine()) return null;

View File

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

View File

@ -31,7 +31,13 @@ public class Stampa extends Opera{
if(!sc.hasNextLine()) return null;
tecnica=sc.nextLine();
if(!sc.hasNextLine()) return null;
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;
pos=sc.nextLine();
if(!sc.hasNextLine()) return null;

View File

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