Fix NextPosizioneLibera e main

This commit is contained in:
La Programmatrice Verde 2025-09-25 16:53:48 +02:00
parent 745acce18e
commit 284de5110f
2 changed files with 6 additions and 8 deletions

View File

@ -39,15 +39,15 @@ public class EsercizioGarage {
case 0: case 0:
break; break;
case 1: case 1:
garage.IngressoAuto(); System.out.println(garage.IngressoAuto());
Pausa(); Pausa();
break; break;
case 2: case 2:
garage.GetPostiOccupati(); System.out.println(garage.GetPostiOccupati());
Pausa(); Pausa();
break; break;
case 3: case 3:
garage.GetPostiLiberi(); System.out.println(garage.GetPostiLiberi());
Pausa(); Pausa();
break; break;
case 4: case 4:

View File

@ -21,11 +21,9 @@ public class Garage {
private int NextPosizioneLibera() { private int NextPosizioneLibera() {
boolean exit = true; boolean exit = true;
int i = 0; int i = -1;
for (; i < this.veicoli.length && exit; i++) { for (; i < this.veicoli.length && this.veicoli[i] != null; ++i) {
if (this.veicoli[i] == null) { ;
exit = false;
}
} }
return i; return i;
} }