Ultimato il sistema di restore del contatore oggetti inseriti id

This commit is contained in:
2013-12-18 01:18:34 +01:00
parent 40157c8ccf
commit 929fe8aaaa
3 changed files with 21 additions and 1 deletions

View File

@@ -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;
}

View File

@@ -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();
}

View File

@@ -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);
}
}
}