MostraPersona
This commit is contained in:
parent
7c340b2dbf
commit
8a46ba8cfd
@ -8,7 +8,7 @@ package ereditarieta;
|
|||||||
*
|
*
|
||||||
* @author Verde
|
* @author Verde
|
||||||
*/
|
*/
|
||||||
public class Calciatore extends Persona{
|
public class Calciatore extends Persona {
|
||||||
String squadra;
|
String squadra;
|
||||||
String numeroMaglia;
|
String numeroMaglia;
|
||||||
|
|
||||||
@ -18,4 +18,10 @@ public class Calciatore extends Persona{
|
|||||||
this.squadra = p_squadra;
|
this.squadra = p_squadra;
|
||||||
this.numeroMaglia = p_numeroMaglia;
|
this.numeroMaglia = p_numeroMaglia;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MostraPersona() {
|
||||||
|
super.MostraPersona();
|
||||||
|
System.out.println("Squadra: " + this.squadra);
|
||||||
|
System.out.println("Numero maglia: " + this.numeroMaglia);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -18,4 +18,10 @@ public class Influencer extends Persona{
|
|||||||
this.numeroFollower = p_numeroFollower;
|
this.numeroFollower = p_numeroFollower;
|
||||||
this.handle = p_handle;
|
this.handle = p_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MostraPersona() {
|
||||||
|
super.MostraPersona();
|
||||||
|
System.out.println("Numero di follower: " + this.numeroFollower);
|
||||||
|
System.out.println("Handle: " + this.handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -22,5 +22,10 @@ public class Persona {
|
|||||||
this.età = p_età;
|
this.età = p_età;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MostraPersona() {
|
||||||
|
System.out.println("Nome: " + this.nome);
|
||||||
|
System.out.println("Cognome: " + this.cognome);
|
||||||
|
System.out.println("Sesso: " + this.sesso);
|
||||||
|
System.out.println("Età: " + this.età);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -18,4 +18,10 @@ public class Studente extends Persona{
|
|||||||
this.classe = p_classe;
|
this.classe = p_classe;
|
||||||
this.indirizzoDiStudio = p_indirizzoDiStudio;
|
this.indirizzoDiStudio = p_indirizzoDiStudio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MostraPersona() {
|
||||||
|
super.MostraPersona();
|
||||||
|
System.out.println("Classe: " + this.classe);
|
||||||
|
System.out.println("Indirizzo di studio: " + this.indirizzoDiStudio);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -21,12 +21,13 @@ public class ereditarieta {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int scelta = -1;
|
int scelta = -1;
|
||||||
Persona persone[];
|
Persona persone[] = null;
|
||||||
|
boolean opzione1 = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
System.out.println("Scegliere un'opzione:");
|
System.out.println("Scegliere un'opzione:");
|
||||||
System.out.println("1. ");
|
System.out.println("1. Inserire le persone");
|
||||||
System.out.println("2. ");
|
System.out.println("2. Mostra persone");
|
||||||
System.out.println("3. ");
|
System.out.println("3. ");
|
||||||
System.out.println("0. Esci");
|
System.out.println("0. Esci");
|
||||||
System.out.print("Opzione: ");
|
System.out.print("Opzione: ");
|
||||||
@ -40,10 +41,15 @@ public class ereditarieta {
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
persone = InserisciPersone();
|
persone = InserisciPersone();
|
||||||
|
opzione1 = true;
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
MostraPersone(persone);
|
if (opzione1) {
|
||||||
|
MostraPersone(persone);
|
||||||
|
} else {
|
||||||
|
System.out.println("Errore: è necessario aggiungere almeno una persona prima di mostrarle.");
|
||||||
|
}
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
@ -156,7 +162,7 @@ public class ereditarieta {
|
|||||||
ritorno[i] = new Calciatore(nome, cognome, sesso, età, squadra, numeroMaglia);
|
ritorno[i] = new Calciatore(nome, cognome, sesso, età, squadra, numeroMaglia);
|
||||||
break;
|
break;
|
||||||
case "influencer":
|
case "influencer":
|
||||||
System.out.print("Inserire il numero di follower: ");
|
System.out.print("Inserire il numero di follower: ");
|
||||||
numeroFollower = sc.nextLine();
|
numeroFollower = sc.nextLine();
|
||||||
sc.nextLine();
|
sc.nextLine();
|
||||||
|
|
||||||
@ -179,4 +185,10 @@ public class ereditarieta {
|
|||||||
}
|
}
|
||||||
return ritorno;
|
return ritorno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void MostraPersone(Persona[] p_persone) {
|
||||||
|
for (Persona persona : p_persone) {
|
||||||
|
persona.MostraPersona();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user