-
Notifications
You must be signed in to change notification settings - Fork 24
chore: reinstate a file that was deleted in Lesson17 #545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4b73af3
35d6838
06470ca
ca74a88
6d9afe2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,4 +85,4 @@ private CheckingAccount getAccountOrThrow(String accountNumber) { | |
} | ||
return account; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.codedifferently.lesson17.bank; | ||
|
||
import java.util.Set; | ||
|
||
public class BusinessChecking extends CheckingAccount { | ||
// By extending the checking account class it will call to the methods of the checking account. | ||
|
||
public BusinessChecking(String accountNumber, Set<Customer> owners, double initialBalance) { | ||
super(accountNumber, owners, initialBalance); | ||
|
||
boolean hasBusinessOwner = | ||
false; // Have a for loop for to detect if the customer is a business owner// | ||
for (Customer owner : owners) { | ||
if (owner.isBusiness()) { | ||
hasBusinessOwner = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!hasBusinessOwner) { // If that customer is not a business owner, it will throw an | ||
// exception// | ||
throw new IllegalArgumentException("Business account must have at least one business owner."); | ||
} | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this file is empty. You might have forgotten to push the code, or perhaps you didn't intend to upload it. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic here seems off, I'm not sure what your intention was. It looks like you were trying to create a superclass called 'Account' to be extended by 'CheckingAccount' and 'SavingsAccount'. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.codedifferently.lesson17.bank; | ||
|
||
public class Account { | ||
|
||
package com.codedifferently.lesson17.bank; | ||
|
||
class account { | ||
public static void main(String[] args) { | ||
static Object getOwners() { | ||
return "Owner information not available."; | ||
} | ||
static Object ›() { | ||
throw new UnsupportedOperationException("Not supported yet."); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.codedifferently.lesson17.bank; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import java.util.Set; | ||
import java.util.UUID; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class BusinessCheckingAccountTest { | ||
|
||
public class BusinessCheckingTest { | ||
|
||
@Test | ||
public void testValidBusinessCheckingAccount() { | ||
Customer bob = new Customer(UUID.randomUUID(), "Bob", true); // is a business | ||
Set<Customer> owners = Set.of(bob); | ||
|
||
BusinessChecking account = new BusinessChecking("BUS-001", owners, 100.0); | ||
assertEquals("BUS-001", account.getAccountNumber()); | ||
} | ||
|
||
@Test | ||
public void testInvalidBusinessCheckingAccountThrowsException() { | ||
Customer alice = new Customer(UUID.randomUUID(), "Alice", false); // personal | ||
Set<Customer> owners = Set.of(alice); | ||
|
||
Exception exception = | ||
assertThrows( | ||
IllegalArgumentException.class, | ||
() -> { | ||
new BusinessChecking("BUS-002", owners, 100.0); | ||
}); | ||
|
||
assertEquals( | ||
"Business account must have at least one business owner.", exception.getMessage()); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class looks good overall. In the class declaration, I'd change the class name from "BusinessChecking" to "BusinessCheckingAccount"