Migliorie
This commit is contained in:
@@ -21,8 +21,9 @@ public class IncontroCulturale extends Evento{
|
||||
private String relatoriToString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String relatore : this.relatori) {
|
||||
sb.append(relatore);
|
||||
sb.append("\n");
|
||||
sb.append("\t");
|
||||
sb.append(relatore);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
|
||||
@@ -21,8 +21,9 @@ public class Mostra extends Evento {
|
||||
private String saleToString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String sala : this.sale) {
|
||||
sb.append(sala);
|
||||
sb.append("\n");
|
||||
sb.append("\t");
|
||||
sb.append(sala);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
|
||||
@@ -48,7 +48,7 @@ public class eventiTriennale {
|
||||
break;
|
||||
case 2:
|
||||
if (eventi == null) {
|
||||
System.out.println();
|
||||
System.out.println(ERRORE_EVENTI_VUOTO);
|
||||
} else {
|
||||
mostraEventi(eventi);
|
||||
}
|
||||
@@ -71,7 +71,12 @@ public class eventiTriennale {
|
||||
if (eventi == null) {
|
||||
System.out.println(ERRORE_EVENTI_VUOTO);
|
||||
} else {
|
||||
scontoCinquePerCentoMostre(eventi);
|
||||
if (!scontoCinquePerCentoMostre(eventi)) {
|
||||
System.out.println("Sconto applicato correttamente.");
|
||||
}
|
||||
else {
|
||||
System.out.println("Nessuna mostra trovata.");
|
||||
}
|
||||
}
|
||||
pausa();
|
||||
break;
|
||||
@@ -98,12 +103,13 @@ public class eventiTriennale {
|
||||
if (eventi != null) {
|
||||
do {
|
||||
error = false;
|
||||
System.out.println("Attenzione: esiste già una lista di eventi. Sovrascriverla? [S/N]");
|
||||
System.out.print("Attenzione: esiste già una lista di eventi. Sovrascriverla? [S/N]");
|
||||
scelta = sc.nextLine().trim().toLowerCase();
|
||||
|
||||
switch (scelta) {
|
||||
case "s":
|
||||
eventi = inserisciEventi();
|
||||
System.out.println("Lista eventi creata correttamente.");
|
||||
break;
|
||||
case "n":
|
||||
System.out.println("La lista non è stata modificata.");
|
||||
@@ -115,6 +121,7 @@ public class eventiTriennale {
|
||||
} while (error);
|
||||
} else {
|
||||
eventi = inserisciEventi();
|
||||
System.out.println("Lista eventi creata correttamente.");
|
||||
}
|
||||
|
||||
return eventi;
|
||||
@@ -136,6 +143,7 @@ public class eventiTriennale {
|
||||
System.out.print("Scelta: ");
|
||||
try {
|
||||
scelta = sc.nextInt();
|
||||
sc.nextLine();
|
||||
|
||||
switch (scelta) {
|
||||
case 1:
|
||||
@@ -239,7 +247,7 @@ public class eventiTriennale {
|
||||
String[] sale = new String[dimensione];
|
||||
|
||||
for (int i = 0; i < sale.length; i++) {
|
||||
System.out.println("Inserire il nome della sala n. " + (i + 1) + ": ");
|
||||
System.out.print("Inserire il nome della sala n. " + (i + 1) + ": ");
|
||||
sale[i] = sc.nextLine().trim();
|
||||
}
|
||||
|
||||
@@ -252,7 +260,7 @@ public class eventiTriennale {
|
||||
String tipologia_musica;
|
||||
String nome;
|
||||
|
||||
System.out.print("Titolo della mostra: ");
|
||||
System.out.print("Titolo del concerto: ");
|
||||
titolo = sc.nextLine().trim();
|
||||
|
||||
prezzo = prezzo();
|
||||
@@ -272,7 +280,7 @@ public class eventiTriennale {
|
||||
String tema;
|
||||
String[] relatori;
|
||||
|
||||
System.out.print("Titolo della mostra: ");
|
||||
System.out.print("Titolo dell'incontro: ");
|
||||
titolo = sc.nextLine().trim();
|
||||
|
||||
prezzo = prezzo();
|
||||
@@ -290,7 +298,7 @@ public class eventiTriennale {
|
||||
String[] relatori = new String[dimensione];
|
||||
|
||||
for (int i = 0; i < relatori.length; i++) {
|
||||
System.out.println("Inserire il nome della/del relatrice/relatore n. " + (i + 1) + ": ");
|
||||
System.out.print("Inserire il nome della/del relatrice/relatore n. " + (i + 1) + ": ");
|
||||
relatori[i] = sc.nextLine().trim();
|
||||
}
|
||||
|
||||
@@ -312,15 +320,22 @@ public class eventiTriennale {
|
||||
sb.append(evento.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sb.append("\n");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
static void scontoCinquePerCentoMostre(Evento[] eventi) {
|
||||
static boolean scontoCinquePerCentoMostre(Evento[] eventi) {
|
||||
boolean noMostre = false;
|
||||
for (Evento evento : eventi) {
|
||||
if (evento instanceof Mostra) {
|
||||
evento.sconto(5);
|
||||
noMostre = false;
|
||||
} else {
|
||||
noMostre = true;
|
||||
}
|
||||
}
|
||||
|
||||
return noMostre;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user