Migliorato il save e restore counter in modo da funzionare anche se ci sono bug o crash
This commit is contained in:
@@ -28,6 +28,10 @@ public class Global {
|
|||||||
Global.general_counter = general_counter;
|
Global.general_counter = general_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getGeneral_counter() {
|
||||||
|
return general_counter;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* E' il contatore statico privato
|
* E' il contatore statico privato
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import it.unisa.info13d.Articoli.Utilizzabile;
|
|||||||
import it.unisa.info13d.Articoli.Vacanze;
|
import it.unisa.info13d.Articoli.Vacanze;
|
||||||
import it.unisa.info13d.Login.Access;
|
import it.unisa.info13d.Login.Access;
|
||||||
import it.unisa.info13d.Login.Entry;
|
import it.unisa.info13d.Login.Entry;
|
||||||
|
import it.unisa.info13d.Utility.IdCounter;
|
||||||
import it.unisa.info13d.Utility.ReShow;
|
import it.unisa.info13d.Utility.ReShow;
|
||||||
import it.unisa.info13d.Login.Access;
|
import it.unisa.info13d.Login.Access;
|
||||||
import it.unisa.info13d.Login.LoggedUser;
|
import it.unisa.info13d.Login.LoggedUser;
|
||||||
@@ -182,6 +183,7 @@ public class Catalogo{
|
|||||||
store_data();
|
store_data();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
IdCounter.save_counter();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancellaProdotto() throws FileNotFoundException, ClassNotFoundException, IOException
|
public void cancellaProdotto() throws FileNotFoundException, ClassNotFoundException, IOException
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class Main {
|
|||||||
ReShow r = new ReShow();
|
ReShow r = new ReShow();
|
||||||
for (;r.reshow;)
|
for (;r.reshow;)
|
||||||
load_catalogo.showMenu(login.getType(),login.getUsername(),r);
|
load_catalogo.showMenu(login.getType(),login.getUsername(),r);
|
||||||
IdCounter.save_counter();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class IdCounter {
|
|||||||
|
|
||||||
public static void save_counter() throws FileNotFoundException,IOException,ClassNotFoundException{
|
public static void save_counter() throws FileNotFoundException,IOException,ClassNotFoundException{
|
||||||
File f_data = new File("id_counter");
|
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));
|
ObjectOutputStream writer = new ObjectOutputStream(new FileOutputStream(f_data));
|
||||||
writer.writeObject(data);
|
writer.writeObject(data);
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user