4
I am studying object-oriented Java programming and need to perform the following exercise:
Implement the class Funcionario
and the class Gerente
.
- Create the class
Assistente
, which is also aFuncionario
, and which has a number of registration (do the methodGET
). Overwrite the methodexibeDados()
. - Knowing that Technical Assistants have a salary bonus and that
Administrative Assistants have a shift (day or night) and an additional
night, create the classes
Tecnico
andAdministrativo
.
I created the following code:
public class Funcionario {
String nome;
String cpf;
double salario;
int matricula;
public void exibeDados(){
System.out.println("Nome: " + nome + " Cpf: " + cpf + " Salário: " + salario + " Matricula: " + matricula);
}
}
public class Gerente extends Funcionario {
String departamento;
}
public class Assistente extends Funcionario{
public void getMatricula(int matricula){
this.matricula = matricula;
}
public void exibeDados(){
System.out.println("Nome: " + nome + " Cpf: " + cpf + " Salário: " + salario + " Matricula: " + this.matricula);
}
}
public class Administrativo extends Assistente {
String turno;
public void adicionalNoturno(double adicional){
if(turno == "noturno" || turno == "Noturno"){
this.salario = this.salario+adicional;
}
}
}
public class Tecnico extends Assistente {
public double bonusSalarial(){
this.salario = this.salario+(this.salario*0.1);
return this.salario;
}
}
Is there some error in the construction of methods and inheritances or some error in general taking into account the statement of the exercise.?
Money I must manipulate with float?
– Gon
No: http://answall.com/a/40048/101. And I strongly advise not to keep creating new accounts, will hinder your learning having a lot of things spread.
– Maniero
I read the answer on the other topic, I didn’t know about the Money class, I’ll study more about it. I just didn’t understand what you meant by creating new accounts, it would be creating classes and classes in Java?
– Gon
No, there are already several users who are yours here on the site, the ideal is that only had one. It would be nice to see them all and ask for a moderator to join in one account.
– Maniero
But it was the first time I created an account here on the site. I had never created an account here. Could I have duplicated the account or given an error? It has to track the email so I see the name of other users with the same email?
– Gon
You are not Aline?
– Maniero
No, my real name is Ewerton.
– Gon
I’m sorry then, she uses some accounts with variations of Gon and asks questions of the same theme and the same way you, passed the impression, forget that part :)
– Maniero
Oh yes! I even scared, I thought someone might be using my email. I am researching about the Java Money class. Thank you so much for all the help, I’m starting studies and I’m finding it a little complicated now at the beginning.
– Gon
I didn’t say you should use it, only that the
double
is not appropriate. Many people thinkMoney
an exaggeration. See also: http://answall.com/q/118407/101 and http://answall.com/a/77747/101– Maniero