Migliorato il save e restore counter in modo da funzionare anche se ci sono bug o crash

This commit is contained in:
2013-12-18 18:23:29 +01:00
parent 4472599169
commit fc9310ad17
4 changed files with 14 additions and 8 deletions

View File

@@ -28,6 +28,10 @@ public class Global {
Global.general_counter = general_counter;
}
public static int getGeneral_counter() {
return general_counter;
}
/**
* E' il contatore statico privato
*/

View File

@@ -7,6 +7,7 @@ import it.unisa.info13d.Articoli.Utilizzabile;
import it.unisa.info13d.Articoli.Vacanze;
import it.unisa.info13d.Login.Access;
import it.unisa.info13d.Login.Entry;
import it.unisa.info13d.Utility.IdCounter;
import it.unisa.info13d.Utility.ReShow;
import it.unisa.info13d.Login.Access;
import it.unisa.info13d.Login.LoggedUser;
@@ -182,6 +183,7 @@ public class Catalogo{
store_data();
break;
}
IdCounter.save_counter();
}
public void cancellaProdotto() throws FileNotFoundException, ClassNotFoundException, IOException

View File

@@ -27,7 +27,7 @@ public class Main {
ReShow r = new ReShow();
for (;r.reshow;)
load_catalogo.showMenu(login.getType(),login.getUsername(),r);
IdCounter.save_counter();

View File

@@ -16,7 +16,7 @@ public class IdCounter {
public static void save_counter() throws FileNotFoundException,IOException,ClassNotFoundException{
File f_data = new File("id_counter");
Integer data = Integer.valueOf(Global.get_next_id() - 1);
Integer data = Integer.valueOf(Global.getGeneral_counter());
ObjectOutputStream writer = new ObjectOutputStream(new FileOutputStream(f_data));
writer.writeObject(data);
writer.close();