Ultimato il sistema di restore del contatore oggetti inseriti id
This commit is contained in:
@@ -24,11 +24,14 @@ public class Global {
|
||||
return general_counter;
|
||||
}
|
||||
|
||||
public static void setGeneral_counter(int general_counter) {
|
||||
Global.general_counter = general_counter;
|
||||
}
|
||||
|
||||
/**
|
||||
* E' il contatore statico privato
|
||||
*/
|
||||
private static int general_counter = 0;
|
||||
private static int general_counter;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import it.unisa.info13d.Utility.IdCounter;
|
||||
import it.unisa.info13d.Utility.ReShow;
|
||||
|
||||
public class Main {
|
||||
@@ -18,12 +19,16 @@ public class Main {
|
||||
LoginData login = new LoginData();
|
||||
login.getUserDataInfo();
|
||||
|
||||
|
||||
IdCounter.restore_counter();
|
||||
Catalogo load_catalogo = new Catalogo();
|
||||
|
||||
|
||||
ReShow r = new ReShow();
|
||||
for (;r.reshow;)
|
||||
load_catalogo.showMenu(login.getType(),r);
|
||||
IdCounter.save_counter();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,19 @@ public class IdCounter {
|
||||
}
|
||||
|
||||
|
||||
public static void restore_counter() throws FileNotFoundException,IOException,ClassNotFoundException{
|
||||
File f_data = new File("id_counter");
|
||||
if ( (f_data.exists())){
|
||||
ObjectInputStream reader = new ObjectInputStream(new FileInputStream(f_data));
|
||||
Integer data = (Integer) reader.readObject();
|
||||
Global.setGeneral_counter(data.intValue());
|
||||
}else{
|
||||
|
||||
Global.setGeneral_counter(0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user