Skip to content

Commit

Permalink
Fait passer le test
Browse files Browse the repository at this point in the history
  • Loading branch information
hal91190 committed Oct 25, 2017
1 parent 99c83f8 commit 03bfcc5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main/java/fr/uvsq/poo/compte/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,19 @@ public void credit(BigDecimal amount) {
balance = balance.add(amount);
}

private static void validateAmount(BigDecimal amount) {
if (amount.compareTo(ZERO) < 0) {
throw new IllegalArgumentException("Montant invalide");
}
}

/**
* Débite le compte.
* @param amount le montant à débiter
* @throws IllegalArgumentException si le montant à débiter est négatif ou s'il est supérieur au solde
*/
public void debit(BigDecimal amount) {
validateAmount(amount);
balance = balance.subtract(amount);
}

private static void validateAmount(BigDecimal amount) {
if (amount.compareTo(ZERO) < 0) {
throw new IllegalArgumentException("Montant invalide");
}
}
}

0 comments on commit 03bfcc5

Please sign in to comment.