Controlli

This commit is contained in:
La Programmatrice Verde
2026-03-20 18:37:11 +01:00
parent 6dddc5aeb6
commit 18d9dd0786

View File

@@ -28,6 +28,8 @@ public class GestioneFerie {
static Scanner sc = new Scanner(System.in);
static final String ERRORE_GENERICO = "Errore: opzione non valida.";
static final String ERRORE_DIPENDENTI_VUOTO = "È necessario inserire almeno un dipendente prima di proseguire.";
static final String ERRORE_RICHIESTE_VUOTO = "Aggiungere almeno una richiesta prima di proseguire.";
static final String FORMATO_DATA = "dd/MM/yyyy";
public static void main(String[] args) {
@@ -58,23 +60,44 @@ public class GestioneFerie {
pausa();
break;
case 2:
richiediFerie(richieste, dipendenti);
if (dipendenti.isEmpty()) {
System.out.println(ERRORE_DIPENDENTI_VUOTO);
} else {
richiediFerie(richieste, dipendenti);
System.out.println("Richiesta di ferie aggiunta con successo.");
System.out.println("La richiesta è attualmente in attesa di approvazione.");
}
pausa();
break;
case 3:
approvaRichiesteFerie(dipendenti, richieste);
if (richieste.isEmpty()) {
System.out.println(ERRORE_RICHIESTE_VUOTO);
} else {
approvaRichiesteFerie(dipendenti, richieste);
}
pausa();
break;
case 4:
System.out.println(
"Giorni di ferie residui: " + getDipendente(dipendenti).getGiorniFerieResidui());
if (dipendenti.isEmpty()) {
System.out.println(ERRORE_DIPENDENTI_VUOTO);
} else {
System.out.println(
"Giorni di ferie residui: " + getDipendente(dipendenti).getGiorniFerieResidui());
}
pausa();
break;
case 5:
mostraDipendentiInFerie(
data("per cui visualizzare i dipendenti in ferie"), dipendenti, richieste);
if (dipendenti.isEmpty()) {
System.out.println(ERRORE_DIPENDENTI_VUOTO);
} else {
if (richieste.isEmpty()) {
System.out.println(ERRORE_RICHIESTE_VUOTO);
} else {
mostraDipendentiInFerie(
data("per cui visualizzare i dipendenti in ferie"), dipendenti, richieste);
}
}
pausa();
break;
default: