-
Notifications
You must be signed in to change notification settings - Fork 24
feat:adds Savings Account file for lesson 17 #529
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4b73af3
feat:added Savings Account file for lesson 17
NelltheWiz 35d6838
feat: adds Business checking account for lesson 17
NelltheWiz 06470ca
fix: checks error for Chanels lesson 17
NelltheWiz ca74a88
chore: fixes bankatm and checking account file
NelltheWiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,4 +85,4 @@ private CheckingAccount getAccountOrThrow(String accountNumber) { | |
} | ||
return account; | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...on_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/BusinessChecking.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
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. Should be |
||
// 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."); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/SavingsAccount.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.codedifferently.lesson17.bank; | ||
|
||
public class SavingsAccount { | ||
|
||
|
||
} |
16 changes: 16 additions & 0 deletions
16
lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/account.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license | ||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template | ||
*/ | ||
|
||
package com.codedifferently.lesson17.bank; | ||
|
||
class account { | ||
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. Wrong class name, should probably be |
||
public static void main(String[] args) { | ||
static Object getOwners() { | ||
return "Owner information not available."; | ||
} | ||
static Object ›() { | ||
throw new UnsupportedOperationException("Not supported yet."); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...bank_app/src/test/java/com/codedifferently/lesson17/bank/BusinessCheckingAccountTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Needed to incorporate changes to this class.