We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bd2aab0 commit 71e7dd2Copy full SHA for 71e7dd2
lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/BankAtm.java
@@ -19,7 +19,16 @@ public class BankAtm {
19
*
20
* @param account The account to add.
21
*/
22
- public void addAccount(CheckingAccount account) {
+ public void addAccount(CheckingAccount account) {
23
+ if (account instanceof BusinessCheckingAccount) {
24
+ boolean hasBusinessAccount = account.getOwners().stream()
25
+ .anyMatch(owner -> owner.isBusiness());
26
+
27
+ if(!hasBusinessAccount) {
28
+ throw new IllegalArgumentException("At least one owning account must be a business account.");
29
+ }
30
31
32
accountByNumber.put(account.getAccountNumber(), account);
33
account
34
.getOwners()
0 commit comments