Inizio metodi PostiOccupati e Liberi
This commit is contained in:
parent
e8f8461679
commit
72cce911ed
@ -33,6 +33,7 @@ public class EsercizioGarage {
|
|||||||
System.out.print("Opzione: ");
|
System.out.print("Opzione: ");
|
||||||
|
|
||||||
scelta = sc.nextInt();
|
scelta = sc.nextInt();
|
||||||
|
sc.nextLine();
|
||||||
|
|
||||||
switch (scelta) {
|
switch (scelta) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -64,6 +65,6 @@ public class EsercizioGarage {
|
|||||||
|
|
||||||
public static void Pausa() {
|
public static void Pausa() {
|
||||||
System.out.println("Premere un tasto per continuare. . .");
|
System.out.println("Premere un tasto per continuare. . .");
|
||||||
sc.next();
|
sc.nextLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,18 +19,24 @@ public class Garage {
|
|||||||
this.veicoli = new Auto[p_dimensione];
|
this.veicoli = new Auto[p_dimensione];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IngressoAuto(){
|
public String IngressoAuto() {
|
||||||
Scanner sc = new Scanner(System.in);
|
Scanner sc = new Scanner(System.in);
|
||||||
String targa;
|
String targa;
|
||||||
|
|
||||||
System.out.println("Inserire la targa dell'auto: ");
|
System.out.println("Inserire la targa dell'auto: ");
|
||||||
targa = sc.next();
|
targa = sc.nextLine();
|
||||||
|
|
||||||
veicoli[this.posizioneLibera++] = new Auto(targa);
|
veicoli[this.posizioneLibera++] = new Auto(targa);
|
||||||
|
|
||||||
System.out.println("L'auto è posteggiata nella posizione %d".formatted(posizioneLibera));
|
return "L'auto è posteggiata nella posizione %d".formatted(posizioneLibera);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String GetPostiOccupati() {
|
||||||
|
return "I posti occupati sono da 0 a %d".formatted(--posizioneLibera);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String GetPostiLiberi() {
|
||||||
|
return "I posti liberi sono da %d a %d".formatted(--posizioneLibera, veicoli.length);
|
||||||
}
|
}
|
||||||
GetPostiOccupati();
|
|
||||||
GetPostiLiberi();
|
|
||||||
UscitaAuto();
|
UscitaAuto();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user