Gestione garage pieno
This commit is contained in:
@@ -19,7 +19,7 @@ public class EsercizioGarage {
|
||||
static Scanner sc = new Scanner(System.in);
|
||||
|
||||
public static void main(String[] args) {
|
||||
int DIMENSIONE_GARAGE = 5;
|
||||
int DIMENSIONE_GARAGE = 3;
|
||||
Garage garage = new Garage(DIMENSIONE_GARAGE);
|
||||
int scelta;
|
||||
|
||||
|
||||
@@ -33,14 +33,20 @@ public class Garage {
|
||||
|
||||
public String IngressoAuto() {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
String targa;
|
||||
String targa, ritorno;
|
||||
|
||||
System.out.println("Inserire la targa dell'auto: ");
|
||||
targa = sc.nextLine();
|
||||
|
||||
veicoli[this.NextPosizioneLibera()] = new Auto(targa);
|
||||
try{
|
||||
veicoli[this.NextPosizioneLibera()] = new Auto(targa);
|
||||
ritorno = "L'auto è posteggiata nella posizione %d".formatted(posizioneLibera++);
|
||||
}
|
||||
catch(ArrayIndexOutOfBoundsException e){
|
||||
ritorno = "Errore: il garage è pieno.";
|
||||
}
|
||||
|
||||
return "L'auto è posteggiata nella posizione %d".formatted(posizioneLibera);
|
||||
return ritorno;
|
||||
}
|
||||
|
||||
public String GetPostiOccupati() {
|
||||
|
||||
Reference in New Issue
Block a user