Skip to content

Instantly share code, notes, and snippets.

@rafaelchagasb
Created December 21, 2011 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelchagasb/1505607 to your computer and use it in GitHub Desktop.
Save rafaelchagasb/1505607 to your computer and use it in GitHub Desktop.
Decorator - Exercício 2
public class ImpostoMuitoAlto extends Imposto{
public ImpostoMuitoAlto(Imposto outroImposto){
super(outroImposto);
}
public ImpostoMuitoAlto() {
}
@Override
public double calcula(Orcamento orcamento) {
return orcamento.getValor()*0.2 + calculoDoOutroImposto(orcamento);
}
}
public class TestaImpostoAlto {
public static void main(String[] args) {
Orcamento orcamento = new Orcamento(700.0);
Imposto impostoComposto = new ImpostoMuitoAlto(new ISS());
System.out.println(impostoComposto.calcula(orcamento));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment