Mostra follower influencer + mostra squadra calciatore
This commit is contained in:
parent
f20411fcd8
commit
08d9afbf4c
@ -24,4 +24,8 @@ public class Calciatore extends Persona {
|
|||||||
System.out.println("Squadra: " + this.squadra);
|
System.out.println("Squadra: " + this.squadra);
|
||||||
System.out.println("Numero maglia: " + this.numeroMaglia);
|
System.out.println("Numero maglia: " + this.numeroMaglia);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSquadra() {
|
||||||
|
return this.squadra;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -23,9 +23,10 @@ public class ereditarieta {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int scelta = -1;
|
int scelta = -1;
|
||||||
Persona persone[] = null;
|
Persona persone[] = null;
|
||||||
boolean opzione1 = false;
|
boolean opzione1 = false, personaTrovata;
|
||||||
String nome;
|
String nome;
|
||||||
Influencer influencerDaMostrare;
|
Influencer influencerDaMostrare = null;
|
||||||
|
Calciatore calciatoreDaMostrare = null;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
System.out.println("Scegliere un'opzione:");
|
System.out.println("Scegliere un'opzione:");
|
||||||
@ -58,34 +59,42 @@ public class ereditarieta {
|
|||||||
}
|
}
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3, 4:
|
||||||
if (opzione1) {
|
if (opzione1) {
|
||||||
if (ProfessioneEsiste(persone, "Influencer")) {
|
if (ProfessioneEsiste(persone, scelta == 3 ? "Influencer" : "Calciatore")) {
|
||||||
System.out.print("Inserire il nome dell'influencer: ");
|
System.out.print("Inserire il nome "
|
||||||
|
+ (scelta == 3 ? "dell'influencer" : "del calciatore") + ": ");
|
||||||
nome = sc.nextLine();
|
nome = sc.nextLine();
|
||||||
|
|
||||||
if ((influencerDaMostrare = (Influencer) TrovaPersonaPerNomeeProfessione(persone, nome,
|
if (scelta == 3) {
|
||||||
"Influencer")) != null) {
|
personaTrovata = (influencerDaMostrare = (Influencer) TrovaPersonaPerNomeeProfessione(persone,
|
||||||
System.out.println("L'influencer di nome " + nome + " ha "
|
nome,
|
||||||
+ influencerDaMostrare.getNumeroFollower() + " follower.");
|
"Influencer")) != null;
|
||||||
|
} else {
|
||||||
|
personaTrovata = (calciatoreDaMostrare = (Calciatore) TrovaPersonaPerNomeeProfessione(
|
||||||
|
persone, nome,
|
||||||
|
"Calciatore")) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (personaTrovata) {
|
||||||
|
System.out.println((scelta == 3 ? "L'influencer" : "Il calciatore") + " di nome " + nome + (scelta == 3 ? " ha "
|
||||||
|
+ influencerDaMostrare.getNumeroFollower() + " follower" : " fa parte della squadra "
|
||||||
|
+ calciatoreDaMostrare.getSquadra()) + ".");
|
||||||
} else {
|
} else {
|
||||||
System.out
|
System.out
|
||||||
.println("Errore: l'influencer di nome " + nome + " non è stato trovato.");
|
.println("Errore: " + ( scelta == 3 ? "l'influencer" : "il calciatore") + " di nome " + nome
|
||||||
|
+ " non è stato trovato.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out
|
System.out
|
||||||
.println(
|
.println(
|
||||||
"Errore: è necessario aggiungere almeno un influencer prima di mostrare i suoi follower.");
|
"Errore: è necessario aggiungere almeno un " + (scelta == 3 ? "influencer" : "calciatore") + " prima di mostrare i suoi follower.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out
|
System.out
|
||||||
.println(
|
.println(
|
||||||
"Errore: è necessario aggiungere almeno una persona prima di mostrare informazioni su di esse.");
|
"Errore: è necessario aggiungere almeno una persona prima di mostrare informazioni su di esse.");
|
||||||
}
|
}
|
||||||
Pausa();
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
|
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
@ -248,7 +257,8 @@ public class ereditarieta {
|
|||||||
boolean error = true;
|
boolean error = true;
|
||||||
|
|
||||||
for (int i = 0; i < p_persone.length && error; i++) {
|
for (int i = 0; i < p_persone.length && error; i++) {
|
||||||
if (p_persone[i].getClass().getSimpleName().equals(p_professione) && p_persone[i].getNome().equals(p_nome)) {
|
if (p_persone[i].getClass().getSimpleName().equals(p_professione)
|
||||||
|
&& p_persone[i].getNome().equals(p_nome)) {
|
||||||
error = false;
|
error = false;
|
||||||
ritorno = p_persone[i];
|
ritorno = p_persone[i];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user