Seth 5 lat temu
rodzic
commit
b3a812a05f

+ 5
- 1
src/main/java/rocks/zipcode/quiz5/objectorientation/account/BankAccount.java Wyświetl plik

@@ -21,7 +21,11 @@ public class BankAccount extends Account implements Transactable{
21 21
 
22 22
 
23 23
     public void deposit(Double amountToIncreaseBy) {
24
-        balance += amountToIncreaseBy;
24
+        if(amountToIncreaseBy >= 0) {
25
+            balance += amountToIncreaseBy;
26
+        } else {
27
+            throw new IllegalArgumentException();
28
+        }
25 29
     }
26 30
 
27 31
     public void withdrawal(Double amountToDecreaseBy) {