1
I have this interface
public interface Promocional {
boolean aplicaDesconto(double porcentagem);
default boolean aplicaDescontoDe10Porcento() {
return aplicaDesconto(0.1);
}
}
The class LivroFisico
that extends the superclass Livro
and implements the interface Promocional
public class LivroFisico extends Livro implements Promocional{
public LivroFisico(Autor autor) {
super(autor);
}
@Override
public boolean aplicaDesconto(double porcentagem) {
// TODO Auto-generated method stub
return true;
}
}
And here in the method main
it does not display properly.
main()
LivroFisico fisico = new LivroFisico(autor);
fisico.setValor(59.90);
if(fisico.aplicaDescontoDe10Porcento()) {
System.out.println("Valor agora e: " + fisico.getValor());
}
It displays 59.90 and not 53.91 which is the discounted amount.
I believe that in class LivroFisico
which is mandatory the use of the method, is giving error.
Sorry for the inconvenience.
– Sanduba
+1 for "It seems to be a thing of following recipes and not learning the concepts" =D
– Bruno César
The guy is
BigDecimal
.– Victor Stafusa
@Victorstafusa is true, confusing me with C# ;)
– Maniero
I just found a lot of conversation for a few questions. The use of the type is not related to the issue itself.
– user6406
@Andréhenriques either you solve the existing problems or you will continue with the problem. It is evident that people make this mistake a lot. The other answer, for example, teaches you to do the wrong thing. I think you think this is good. I don’t think it and in general people here don’t think so. Teaching wrong is always a bad thing. But you can respond in your own way and see if the AP changes acceptance to yours. It seems to me that he has learned something from this. Some like to learn right, others prefer to do it anyway.
– Maniero
@Bigown, that type information was very good, but it applies to the comment and not the answer.
– user6406