Impostazione dati

This commit is contained in:
La Programmatrice Verde
2026-03-19 22:50:04 +01:00
parent 48dc167eb1
commit a199fcf093
3 changed files with 35 additions and 2 deletions

View File

@@ -5,7 +5,7 @@ public class Dipendente {
private String nome;
private String cognome;
private int giorniFerieResidui = 0;
private static final int GIORNI_FERIE_TOTALI = 35;
public static final int GIORNI_FERIE_TOTALI = 35;
public Dipendente(String codiceFiscale, String nome, String cognome) {
this.codiceFiscale = codiceFiscale;
@@ -25,4 +25,9 @@ public class Dipendente {
return cognome;
}
public void setGiorniFerieResidui(int giorniFerieResidui) {
this.giorniFerieResidui = giorniFerieResidui;
}
}

View File

@@ -199,10 +199,32 @@ public class GestioneFerie {
} while (error);
richieste.add(new Richiesta_Ferie(codiceFiscale, inizio, fine));
getDipendente(codiceFiscale, dipendenti).setGiorniFerieResidui((int) (fine.getTimeInMillis() / (24 * 60 * 60 * 1000)
- inizio.getTimeInMillis() / (24 * 60 * 60 * 1000)));
}
private static Dipendente getDipendente(String codiceFiscale, ArrayList<Dipendente> dipendenti) {
for (Dipendente dipendente : dipendenti) {
if (dipendente.getCodiceFiscale().equals(codiceFiscale)) {
return dipendente;
}
}
return null;
}
private static Dipendente getDipendente(String nome, String cognome, String codiceFiscale, ArrayList<Dipendente> dipendenti) {
for (Dipendente dipendente : dipendenti) {
if (dipendente.getNome().equals(nome) && dipendente.getCognome().equals(cognome) && dipendente.getCodiceFiscale().equals(codiceFiscale)) {
return dipendente;
}
}
return null;
}
private static boolean isPeriodoValido(Calendar inizio, Calendar fine) {
return inizio.before(fine) && inizio.after(new Date()) && fine.getTimeInMillis() / (24 * 60 * 60 * 1000) >= 1; // da millisecondi a giorni
return inizio.before(fine) && inizio.after(new Date()) && fine.getTimeInMillis() / (24 * 60 * 60 * 1000) >= 1 && (int) (fine.getTimeInMillis() / (24 * 60 * 60 * 1000)
- inizio.getTimeInMillis() / (24 * 60 * 60 * 1000)) <= Dipendente.GIORNI_FERIE_TOTALI; // da millisecondi a giorni
}
private static String richiestaExists(String codiceFiscale, Calendar inizio, Calendar fine,

View File

@@ -19,6 +19,8 @@ public class Richiesta_Ferie {
this.codiceFiscale = codiceFiscale;
this.inizio = inizio;
this.fine = fine;
this.giorniFerie = (int) (fine.getTimeInMillis() / (24 * 60 * 60 * 1000)
- inizio.getTimeInMillis() / (24 * 60 * 60 * 1000));
}
public String getCodiceFiscale() {
@@ -36,4 +38,8 @@ public class Richiesta_Ferie {
return stato;
}
public int getGiorniFerie() {
return giorniFerie;
}
}