First, do not be scared by the size of the question kkkkk I am studying the OOP course in Java, and the teacher has passed some content there that has not had time to write the code. Then I have a little doubt! I have 3 classes in java. The classes SalaAula, Pessoa and Professor.
SalaAula.java
import java.util.Scanner;
public class SalaAula {
private String nomeAluno;
private int idadeAluno;
private float pesoAluno;
private float alturaAluno;
private int matriculaAluno;
SalaAula() {
System.out.println("Seja bem vindo\n\n ");
Scanner entrada = new Scanner(System.in);
Professor professor = new Professor("Anderson", 32, 1.75f, 110f, 1010220, "Mestre");
System.out.println("Qual seu nome? ");
nomeAluno = entrada.next();
System.out.println("Qual a sua idade? ");
idadeAluno = entrada.nextInt();
System.out.println("Qual o seu peso? ");
pesoAluno = entrada.nextFloat();
System.out.println("Qual a sua altura?");
alturaAluno = entrada.nextFloat();
System.out.println("Qual a sua matrícula?");
matriculaAluno = entrada.nextInt();
//Pessoa pessoa = new Pessoa(nome, idade, peso, altura, peso, matricula);
System.out.println(new Professor());
System.out.println("\n------------------------------------------");
System.out.println("Nome:\tIdade:\tPeso:\tAltura:\tMatrícula:");
System.out.println("------------------------------------------");
System.out.println(nomeAluno + "\t" + idadeAluno + " anos\t" + alturaAluno + "\t" + pesoAluno + "\t" + matriculaAluno);
System.out.println("------------------------------------------");
}
public static void main(String[] args) {
SalaAula principal = new SalaAula();
}
}
Pessoa.java
class Pessoa {
private int idade;
private String nome;
private float altura;
private float peso;
private int matricula;
Pessoa() {
}
Pessoa(String nome, int idade, float altura, float peso, int matricula) {
this.idade = idade;
this.nome = nome;
this.altura = altura;
this.peso = peso;
this.matricula = matricula;
}
public String getNome() {
return this.nome;
}
public void setAltura(float altura) {
this.altura = altura;
}
public void setPeso(float peso) {
this.peso = peso;
}
public void setIdade(int idade) {
this.idade = idade;
}
public void setNome(String nome) {
this.nome = nome;
}
public int getIdade() {
return this.idade;
}
public float getAltura() {
return this.altura;
}
public float getPeso() {
return this.peso;
}
public void setMatricula(int matricula) {
this.matricula = matricula;
}
public int getMatricula() {
return this.matricula;
}
}
Professor.java
public class Professor extends Pessoa {
String nivelSuperior;
Professor() {
}
Professor(String nome, int idade, float altura, float peso, int matricula, String nivel) {
setNome(nome);
setIdade(idade);
setAltura(altura);
setPeso(peso);
setMatricula(matricula);
this.nivelSuperior = nivel;
}
public String getNivel() {
return this.nivelSuperior;
}
public void setNivel(String nivel) {
this.nivelSuperior = nivel;
}
}
That's it! It is to return the information of the teacher:
Professor professor = new Professor("Anderson", 32, 1.75f, 110f, 1010220, "Mestre");
And the student information, which in this case will be entered by the user.
My question is: how do I print teacher information + student information?