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("Numero maglia: " + this.numeroMaglia);
|
||||
}
|
||||
|
||||
public String getSquadra() {
|
||||
return this.squadra;
|
||||
}
|
||||
}
|
||||
@ -23,9 +23,10 @@ public class ereditarieta {
|
||||
public static void main(String[] args) {
|
||||
int scelta = -1;
|
||||
Persona persone[] = null;
|
||||
boolean opzione1 = false;
|
||||
boolean opzione1 = false, personaTrovata;
|
||||
String nome;
|
||||
Influencer influencerDaMostrare;
|
||||
Influencer influencerDaMostrare = null;
|
||||
Calciatore calciatoreDaMostrare = null;
|
||||
|
||||
do {
|
||||
System.out.println("Scegliere un'opzione:");
|
||||
@ -58,34 +59,42 @@ public class ereditarieta {
|
||||
}
|
||||
Pausa();
|
||||
break;
|
||||
case 3:
|
||||
case 3, 4:
|
||||
if (opzione1) {
|
||||
if (ProfessioneEsiste(persone, "Influencer")) {
|
||||
System.out.print("Inserire il nome dell'influencer: ");
|
||||
if (ProfessioneEsiste(persone, scelta == 3 ? "Influencer" : "Calciatore")) {
|
||||
System.out.print("Inserire il nome "
|
||||
+ (scelta == 3 ? "dell'influencer" : "del calciatore") + ": ");
|
||||
nome = sc.nextLine();
|
||||
|
||||
if ((influencerDaMostrare = (Influencer) TrovaPersonaPerNomeeProfessione(persone, nome,
|
||||
"Influencer")) != null) {
|
||||
System.out.println("L'influencer di nome " + nome + " ha "
|
||||
+ influencerDaMostrare.getNumeroFollower() + " follower.");
|
||||
if (scelta == 3) {
|
||||
personaTrovata = (influencerDaMostrare = (Influencer) TrovaPersonaPerNomeeProfessione(persone,
|
||||
nome,
|
||||
"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 {
|
||||
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 {
|
||||
System.out
|
||||
.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 {
|
||||
System.out
|
||||
.println(
|
||||
"Errore: è necessario aggiungere almeno una persona prima di mostrare informazioni su di esse.");
|
||||
}
|
||||
Pausa();
|
||||
break;
|
||||
case 4:
|
||||
|
||||
Pausa();
|
||||
break;
|
||||
case 5:
|
||||
@ -248,7 +257,8 @@ public class ereditarieta {
|
||||
boolean error = true;
|
||||
|
||||
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;
|
||||
ritorno = p_persone[i];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user