3
Guys I am studying the POO discipline in Java, I the teacher spent a content there that did not give time to write the code. Then I’ve got one hell of a question! I have 3 classes in java. 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.
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;
}
}
So here’s the deal! It’s to return the teacher’s information:
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?
I’m cracking my head with this... I know it’s simple, but I’m Noob, so come on over here kkkkk
Thank you.
But select the list? I haven’t seen arraylist or array in any of the classes.
– user28595
It’s all I have... That’s why I wanted help to make him return these values.
– Sandson Costa
I think I put the wrong word in the question.... The list that is to print is only: <pre> Teacher = new Teacher("Anderson", 32, 1.75f, 110f, 1010220, "Master");</pre> and input information.
– Sandson Costa