Skip to content

Commit 5fa42dc

Browse files
author
AmiyahJo
committed
fix: changes the constructor code
moves the boolean for hasBusinessOwner to simply if one owner isn't business
1 parent f6868a2 commit 5fa42dc

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/BusinessCheckingAccount.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ public class BusinessCheckingAccount extends CheckingAccount{
1515
*/
1616
public BusinessCheckingAccount(String accountNumber, Set<Customer> owners, String businessName, double initialBalance) {
1717
super(accountNumber, owners, initialBalance);
18+
this.businessName = businessName;
1819

19-
boolean hasBusinessOwner = owners.stream().anyMatch(Customer::isBusiness);
20-
if (!hasBusinessOwner) {
20+
if (owners.stream().noneMatch(owner -> owner.isBusiness())) {
2121
throw new IllegalArgumentException("At least one owner must be a business.");
2222
}
23-
this.businessName = businessName;
2423
}
2524

2625
public String getBusinessName() {

0 commit comments

Comments
 (0)