6
In this method:
public boolean aplicaDescontoDe(double porcentagem) {
if(porcentagem > 0.3) {
return false;
} else {
this.valor -= valor * porcentagem;
return true;
}
}
What the operator means !
there in the code if
:
if(!livro.aplicaDescontoDe(0.1)) {
System.out.println("Desconto nao pode ser maior que 30%");
} else {
System.out.println("Valor com desconto: " + livro.valor);
}
It is a negation, ie is denying (or reversing the result) the result of the method
aplicaDescontoDe
– rubStackOverflow
In this MSDN link there is a complete explanation, with examples: Negation Operator - MSDN
– Deividson M Goulart
I have a small impression that this question is duplicated.
– Wallace Maxters
deusculpa did not know.
– user38537
@user38537 no need to apologize, even if it is duplicate is good for the site. More chance of someone finding the answers, because they are linked. Suddenly someone searches the Internet and finds his first.
– Bacco
@Wallacemaxters he didn’t say it wasn’t to close.
– Maniero