Skip to content

Commit c763a62

Browse files
committed
Feat: Fix; multiple fixes
1 parent d78260e commit c763a62

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class CheckingAccount {
99
private final Set<Customer> owners;
1010
private final String accountNumber;
1111
private double balance;
12-
private boolean isActive;
12+
public boolean isActive;
1313

1414
/**
1515
* Creates a new checking account.

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ public static <T> boolean isBusiness(T t) {
2020
*
2121
* @param id The ID of the customer.
2222
* @param name The name of the customer.
23+
* @param b
2324
*/
24-
public Customer(UUID id, String name) {
25+
public Customer(UUID id, String name, boolean b) {
2526
this.id = id;
2627
this.name = name;
2728
}
@@ -83,4 +84,8 @@ public boolean equals(Object obj) {
8384
public String toString() {
8485
return "Customer{" + "id=" + id + ", name='" + name + '\'' + '}';
8586
}
87+
88+
public static String getEmail() {
89+
return Customer.getEmail();
90+
}
8691
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.codedifferently.lesson17.bank.exceptions;
2+
3+
import com.codedifferently.lesson17.bank.CheckingAccount;
4+
import com.codedifferently.lesson17.bank.Customer;
5+
import java.util.Set;
6+
7+
public class BusinessAccount {
8+
public class BusinessCheckingAccount extends CheckingAccount {
9+
public BusinessCheckingAccount(String accountNumber, Set<Customer> owners, double balance) {
10+
super(accountNumber, owners, balance);
11+
if (!hasBusinessOwner(owners)) {
12+
throw new IllegalArgumentException("requires at least one business owner.");
13+
}
14+
}
15+
16+
private boolean hasBusinessOwner(Set<Customer> owners) {
17+
return owners.stream()
18+
.anyMatch(
19+
owner -> {
20+
return ((Customer) owners).getEmail().contains("business");
21+
});
22+
}
23+
24+
@Override
25+
public String toString() {
26+
return "BusinessCheckingAccount{"
27+
+ "accountNumber='"
28+
+ getAccountNumber()
29+
+ '\''
30+
+ ", balance="
31+
+ getBalance()
32+
+ ", isActive="
33+
+ isActive
34+
+ '}';
35+
}
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)