Skip to content

Commit 06470ca

Browse files
committed
fix: checks error for Chanels lesson 17
1 parent 35d6838 commit 06470ca

File tree

10 files changed

+51
-76
lines changed

10 files changed

+51
-76
lines changed
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
package com.codedifferently.lesson17;
22

3-
import java.util.HashMap;
4-
import java.util.Map;
5-
import java.util.Set;
6-
import java.util.UUID;
7-
8-
9-
10-
//* Represents a Savings account */
11-
public class SavingsAccount {
12-
13-
}
3+
// * Represents a Savings account */
4+
public class SavingsAccount {}
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
package com.codedifferently.lesson17.bank;
22

3-
import java.util.HashMap;
4-
import java.util.Map;
5-
import java.util.Set;
6-
import java.util.UUID;
7-
8-
import org.apache.logging.log4j.LogManager;
9-
import org.apache.logging.log4j.Logger;
10-
11-
//* Represents an Audit log. */
12-
public class AuditLog {
13-
14-
}
3+
// * Represents an Audit log. */
4+
public class AuditLog {}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package com.codedifferently.lesson17.bank;
22

3+
import com.codedifferently.lesson17.bank.exceptions.AccountNotFoundException;
34
import java.util.HashMap;
45
import java.util.Map;
56
import java.util.Set;
67
import java.util.UUID;
78

8-
import com.codedifferently.lesson17.bank.exceptions.AccountNotFoundException;
9-
109
/** Represents a bank ATM. */
1110
public class BankAtm {
1211

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@
22

33
import java.util.Set;
44

5-
public class BusinessChecking extends CheckingAccount {
6-
//By extending the checking account class it will call to the methods of the
5+
public class BusinessChecking extends CheckingAccount {
6+
// By extending the checking account class it will call to the methods of the checking account.
77

8-
public BusinessChecking(String accountNumber, Set<Customer> owners, double initialBalance) {
9-
super(accountNumber, owners, initialBalance);
8+
public BusinessChecking(String accountNumber, Set<Customer> owners, double initialBalance) {
9+
super(accountNumber, owners, initialBalance);
1010

11-
boolean hasBusinessOwner = false;
12-
for (Customer owner : owners) {
13-
if (owner.isBusiness()) {
14-
hasBusinessOwner = true;
15-
break;
16-
}
17-
}
11+
boolean hasBusinessOwner =
12+
false; // Have a for loop for to detect if the customer is a business owner//
13+
for (Customer owner : owners) {
14+
if (owner.isBusiness()) {
15+
hasBusinessOwner = true;
16+
break;
17+
}
18+
}
1819

19-
if (!hasBusinessOwner) {
20-
throw new IllegalArgumentException("Business account must have at least one business owner.");
21-
}
20+
if (!hasBusinessOwner) { // If that customer is not a business owner, it will throw an
21+
// exception//
22+
throw new IllegalArgumentException("Business account must have at least one business owner.");
2223
}
24+
}
2325
}

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

Lines changed: 0 additions & 5 deletions
This file was deleted.

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.codedifferently.lesson17.bank;
22

3-
import java.util.Set;
4-
53
import com.codedifferently.lesson17.bank.exceptions.InsufficientFundsException;
4+
import java.util.Set;
65

76
/** Represents a checking account. */
87
public class CheckingAccount {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ public String toString() {
7979
}
8080

8181
public boolean isBusiness() {
82-
return isBusiness;
82+
return isBusiness;
8383
}
8484
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55

66
package com.codedifferently.lesson17.bank;
77

8-
98
class account {
109

11-
static Object getOwners() {
12-
throw new UnsupportedOperationException("Not supported yet.");
13-
}
14-
10+
static Object getOwners() {
11+
throw new UnsupportedOperationException("Not supported yet.");
12+
}
1513
}

lesson_17/bank/bank_app/src/test/java/com/codedifferently/lesson17/bank/BankAtmTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
package com.codedifferently.lesson17.bank;
22

3-
import java.util.Set;
4-
import java.util.UUID;
5-
63
import static org.assertj.core.api.Assertions.assertThat;
74
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
8-
import org.junit.jupiter.api.BeforeEach;
9-
import org.junit.jupiter.api.Test;
105

116
import com.codedifferently.lesson17.bank.exceptions.AccountNotFoundException;
127
import com.codedifferently.lesson17.bank.exceptions.CheckVoidedException;
8+
import java.util.Set;
9+
import java.util.UUID;
10+
import org.junit.jupiter.api.BeforeEach;
11+
import org.junit.jupiter.api.Test;
1312

1413
class BankAtmTest {
1514

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
11
package com.codedifferently.lesson17.bank;
22

3-
import java.util.Set;
4-
import java.util.UUID;
5-
63
import static org.junit.jupiter.api.Assertions.assertEquals;
74
import static org.junit.jupiter.api.Assertions.assertThrows;
5+
6+
import java.util.Set;
7+
import java.util.UUID;
88
import org.junit.jupiter.api.Test;
99

1010
public class BusinessCheckingAccountTest {
1111

12-
13-
public class BusinessCheckingTest {
12+
public class BusinessCheckingTest {
1413

1514
@Test
1615
public void testValidBusinessCheckingAccount() {
17-
Customer bob = new Customer(UUID.randomUUID(), "Bob", true); // is a business
18-
Set<Customer> owners = Set.of(bob);
16+
Customer bob = new Customer(UUID.randomUUID(), "Bob", true); // is a business
17+
Set<Customer> owners = Set.of(bob);
1918

20-
BusinessChecking account = new BusinessChecking("BUS-001", owners, 100.0);
21-
assertEquals("BUS-001", account.getAccountNumber());
19+
BusinessChecking account = new BusinessChecking("BUS-001", owners, 100.0);
20+
assertEquals("BUS-001", account.getAccountNumber());
2221
}
2322

2423
@Test
2524
public void testInvalidBusinessCheckingAccountThrowsException() {
26-
Customer alice = new Customer(UUID.randomUUID(), "Alice", false); // personal
27-
Set<Customer> owners = Set.of(alice);
28-
29-
Exception exception = assertThrows(IllegalArgumentException.class, () -> {
30-
new BusinessChecking("BUS-002", owners, 100.0);
31-
});
32-
33-
assertEquals("Business account must have at least one business owner.", exception.getMessage());
25+
Customer alice = new Customer(UUID.randomUUID(), "Alice", false); // personal
26+
Set<Customer> owners = Set.of(alice);
27+
28+
Exception exception =
29+
assertThrows(
30+
IllegalArgumentException.class,
31+
() -> {
32+
new BusinessChecking("BUS-002", owners, 100.0);
33+
});
34+
35+
assertEquals(
36+
"Business account must have at least one business owner.", exception.getMessage());
3437
}
35-
}
36-
38+
}
3739
}

0 commit comments

Comments
 (0)