Hello .. I need help setting up a Java program with the following specifications:
1) Read the following items from the user: Name (String), Age (int), Genre (char [M or F]), Phone (String), Address (String), cpf (String), rg (String), Neighborhood uf (String), ra (if it is a student) (String), course (if it is a student) (String), rp (if it is a teacher) for teacher) (double).
2) It is necessary to create a class called "Student", which has the student attributes. - Created class
package SistemaAcademico;
public class Aluno extends Pessoa {
public Aluno(String nome, int idade, char genero, String telefone, String endereco, String cpf, String rg, String bairro, String cidade, String uf) {
super(nome, idade, genero, telefone, endereco, cpf, rg, bairro, cidade, uf);
}
String ra;
String curso;
}
3) It is necessary to create a class called "Teacher", which has the attributes of teachers. - Created Class
package SistemaAcademico;
public class Professor extends Pessoa {
public Professor(String nome, int idade, char genero, String telefone, String endereco, String cpf, String rg, String bairro, String cidade, String uf) {
super(nome, idade, genero, telefone, endereco, cpf, rg, bairro, cidade, uf);
}
String rp;
String disciplinaMinistrada;
double salario;
}
4) It is necessary to create a class called "Person", which has the common attributes between Students and Teachers. - Created class
package SistemaAcademico;
import java.util.Scanner;
public class Pessoa {
private String nome;
private int idade;
private char genero;
private String telefone;
private String endereco;
private String cpf;
private String rg;
private String bairro;
private String cidade;
private String uf;
public Pessoa(String nome, int idade, char genero, String telefone, String endereco, String cpf, String rg, String bairro, String cidade, String uf) {
this.nome = nome;
this.idade = idade;
this.genero = genero;
this.telefone = telefone;
this.endereco = endereco;
this.cpf = cpf;
this.rg = rg;
this.bairro = bairro;
this.cidade = cidade;
this.uf = uf;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public int getIdade() {
return idade;
}
public void setIdade(int idade) {
this.idade = idade;
}
public char getGenero() {
return genero;
}
public void setGenero(char genero) {
this.genero = genero;
}
public String getTelefone() {
return telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
public String getEndereco() {
return endereco;
}
public void setEndereco(String endereco) {
this.endereco = endereco;
}
public String getCpf() {
return cpf;
}
public void setCpf(String cpf) {
this.cpf = cpf;
}
public String getRg() {
return rg;
}
public void setRg(String rg) {
this.rg = rg;
}
public String getBairro() {
return bairro;
}
public void setBairro(String bairro) {
this.bairro = bairro;
}
public String getCidade() {
return cidade;
}
public void setCidade(String cidade) {
this.cidade = cidade;
}
public String getUf() {
return uf;
}
public void setUf(String uf) {
this.uf = uf;
}
}
5) The Person class must have a method that overrides the "toString" method, so that it prints all Person data.
6) Use the polymorphism so that the Student class can override the "toString" method, so that it delegates to the superclass the writing of the attributes of the Person class and prints out the unique methods of the Student class.
7) Use the polymorphism, so that the Teacher class can override the "toString" method, so that it delegates to the superclass writing the attributes of the Person class and prints out the unique methods of the Teacher class.
(Where should I use toString in each class?)
8) Create a method with the identification name in the Main class, which can be called without the need to instantiate an object (ie directly from the class). This method should not receive parameters and should print the following message: "Student Name - Student RA".
9) The user, when entering the data, must enter 1 to insert a Student or 2 to insert a Teacher. After selecting what you want to insert, you must enter the fields to be inserted in the respective register, that is, if it is 1, all Student data, if it is 2, all the teacher data. The data must be entered into a variable of the selected type. - Created
package SistemaAcademico;
import java.util.Scanner;
public class Principal {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int opcao = 0;
do {
System.out.println("##ESCOLHA UMA OPÇÃO\n");
System.out.println("1 - Cadastrar Aluno");
System.out.println("2 - Cadastrar Professor");
System.out.println("3 - Sair\n");
System.out.println("Digite uma opção: ");
opcao = scan.nextInt();
switch (opcao){
case 1:
cadastro.cadastrarAluno();
break;
case 2:
cadastro.cadastrarProfessor();
break;
case 3:
break;
default:
System.out.println("Esta não é uma opção válida!");
}
} while (opcao !=3 );
}
}
10) After entering the data, the system should print the same.
11) Rules to follow: a) The registration of students under the age of 18 is not allowed. You should show a message asking you to enter the acceptable age b) The registration of teachers under 21 years old is not allowed. You should show a message asking you to enter the acceptable age;
(I do not know where to enter these rules)