Skip to content

Commit b95940c

Browse files
feat: adds BusinessChecking and adds a field for customers to be a business
1 parent 546128f commit b95940c

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.codedifferently.lesson17.bank;
2+
3+
import java.util.Set;
4+
5+
public class BusinessCheckingAccount extends CheckingAccount {
6+
private boolean isActive;
7+
8+
/**
9+
* Creates a new business checking account.
10+
*
11+
* @param accountNumber The account number.
12+
* @param owners The owners of the account.
13+
* @param initialBalance The initial balance of the account.
14+
*/
15+
public BusinessCheckingAccount(String accountNumber, Set<Customer> owners, double initialBalance) {
16+
super(accountNumber, owners, initialBalance);
17+
isActive = true;
18+
}
19+
20+
21+
22+
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ public class Customer {
1010
private final UUID id;
1111
private final String name;
1212
private final Set<CheckingAccount> accounts = new HashSet<>();
13+
private boolean isBusiness;
1314

1415
/**
1516
* Creates a new customer.
1617
*
1718
* @param id The ID of the customer.
1819
* @param name The name of the customer.
1920
*/
20-
public Customer(UUID id, String name) {
21+
public Customer(UUID id, String name, boolean isBusiness) {
2122
this.id = id;
2223
this.name = name;
24+
this.isBusiness = isBusiness;
2325
}
2426

2527
/**
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.codedifferently.lesson17.bank;
2+
3+
public class MoneyOrder {
4+
private double amount;
5+
private CheckingAccount account;
6+
7+
8+
9+
/**
10+
* Creates a new check.
11+
*
12+
* @param checkNumber The check number.
13+
* @param amount The amount of the check.
14+
* @param account The account the check is drawn on.
15+
*/
16+
public MoneyOrder(double amount, CheckingAccount account) {
17+
if (amount < 0) {
18+
throw new IllegalArgumentException("Money Order amount must be positive");
19+
}
20+
this.amount = amount;
21+
this.account = account;
22+
}
23+
}

0 commit comments

Comments
 (0)