From 117eef00bc24fda354ab118df0b19694fa110aa2 Mon Sep 17 00:00:00 2001 From: Orange_dugongo Date: Mon, 28 Nov 2016 20:14:54 +0100 Subject: [PATCH] ricorsione --- src/AziendaExtends/Azienda.java | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/AziendaExtends/Azienda.java b/src/AziendaExtends/Azienda.java index c7c707c..f4e243f 100644 --- a/src/AziendaExtends/Azienda.java +++ b/src/AziendaExtends/Azienda.java @@ -21,19 +21,15 @@ public class Azienda{ private Dipendente read(Scanner sc) throws Exception{ String id; - try{ - if(!sc.hasNext()) return null; - id=sc.next(); - if(id.equals("OP")) - return Operaio.read(sc); - else if(id.equals("DIR")) - return Dirigente.read(sc); - else - throw new IOException("Classe non presente"); - } - catch(IOException Exception){ - System.err.println("***"+Exception.getMessage()+"***"); - return null; + if(!sc.hasNext()) return null; + id=sc.next(); + if(id.equals("OP")) + return Operaio.read(sc); + else if(id.equals("DIR")) + return Dirigente.read(sc); + else{ + sc.nextLine(); + return read(sc); } }