Skip to content

Instantly share code, notes, and snippets.

@CristianoRC
Created April 20, 2019 13:59
Show Gist options
  • Save CristianoRC/e2bbdf5f6e416581ac5c6a80783b61c2 to your computer and use it in GitHub Desktop.
Save CristianoRC/e2bbdf5f6e416581ac5c6a80783b61c2 to your computer and use it in GitHub Desktop.
double calcularDesconto(
double valorInicial, double desconto, bool ehPorcentagem) {
if (desconto <= 0)
throw new ArgumentError("O desconto deve ser maior que zero!");
if (valorInicial <= 0)
throw new ArgumentError("O valor inicial deve ser maior que zero!");
if (ehPorcentagem) {
return valorInicial - (valorInicial * desconto / 100);
}
return valorInicial - desconto;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment