Skip to content

Instantly share code, notes, and snippets.

@luizjacomn
Last active November 22, 2019 12:06
Show Gist options
  • Save luizjacomn/0aac2b630300038fa14b91afbe5830a8 to your computer and use it in GitHub Desktop.
Save luizjacomn/0aac2b630300038fa14b91afbe5830a8 to your computer and use it in GitHub Desktop.
void main() {
Imposto icms = ICMS();
Imposto iptu = IPTU();
CalculoImposto calc = CalculoImposto();
print(calc.calcularImposto(icms, 100));
print(calc.calcularImposto(iptu, 50));
}
abstract class Imposto {
double calcular(double valor);
}
class CalculoImposto {
double calcularImposto(Imposto imposto, double valor) {
return imposto.calcular(valor);
}
}
class ICMS extends Imposto {
double calcular(double valor) {
print('Calculando ICMS:');
return 0.08 * valor;
}
}
class IPTU extends Imposto {
double calcular(double valor) {
print('Calculando IPTU:');
return 0.1 * valor;
}
}
// OUTROS IMPOSTOS QUE PODERIA PRECISAR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment