Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
21c78f1
update isEmailValidTest
Jan 30, 2020
7fce707
update withdraw documentation and withdrawTest
Jan 30, 2020
10f7368
implemented withdraw and isEmailVaild
Jan 30, 2020
5de984e
add withdrawTest and isEmailValidTest comments
Jan 30, 2020
7d8d1fb
improve withdrawTest
Jan 30, 2020
97de2b5
update getBalanceTest
Jan 30, 2020
0e6499f
added isAmountValid header and isAmountValidTest
Jan 30, 2020
d52080d
implemented isAmountValid and fixed incorrect test
Jan 30, 2020
f9825cf
updated withdrawTest and constructorTest
Jan 31, 2020
62991c1
updated comstructor and withdraw to use isValidAmount and fixed incor…
Jan 31, 2020
3026fe6
add deposit method header and comments and depositTest
Jan 31, 2020
0927996
added deposit implementation
Jan 31, 2020
f16a70d
add transfer method header and comments, and transferTest
Jan 31, 2020
932dd01
implemented transfer and fixed incorrect tests
Jan 31, 2020
27cc513
added bank interface java files
Feb 3, 2020
a225a5b
untracked .idea files and updated .gitignore
Feb 4, 2020
15d0153
fixed typo checkTotalAssets to calcTotalAssets
Feb 4, 2020
79f3d05
adding SoftwareEngineeringPractice.iml to gitignore
Feb 4, 2020
2092222
remove SoftwareEngineeringPractive.iml
Feb 4, 2020
6568d75
Refactored code to follow class diagram
Blarfnip Feb 5, 2020
9e802fb
Merge pull request #1 from eostendarp/initial-refactor
eostendarp Feb 5, 2020
cbc6081
Saul made me do so much extra work
Feb 5, 2020
3204e6d
RE:Saul made me do so much extra work
Feb 5, 2020
b2070dd
implemented Account.deposit
Feb 5, 2020
840db4e
Added tests for account.deposit
JoshHayden Feb 5, 2020
887bb5d
Saul didn't finish implementing SavingAccount constructor so I need t…
Feb 5, 2020
efdce0d
added tests for deposit, isEmailValid, and constructor
Blarfnip Feb 5, 2020
b86a4c1
Merge pull request #2 from eostendarp/eostendarp-deposit
eostendarp Feb 5, 2020
e70b0fa
implemented Account deposit and constructor
Blarfnip Feb 5, 2020
daf1b19
Merge branch 'master' of https://github.com/eostendarp/SoftwareEngine…
Blarfnip Feb 5, 2020
6110ad7
Merge pull request #3 from eostendarp/samster-deposit
Blarfnip Feb 5, 2020
996bd4b
Implemented deposit
JoshHayden Feb 5, 2020
aa1cefe
Added use case diagram to README
JoshHayden Feb 5, 2020
bed6fcc
Merge branch 'master' into josh-merge-conflict
JoshHayden Feb 6, 2020
6019dbe
Added Admin constructor test, had to add a default false for isFrozen…
JoshHayden Feb 7, 2020
b50ad76
Implemented admin constructor
JoshHayden Feb 7, 2020
e7dd6aa
Had to mess with Account constructor so they have IDs, updated constr…
JoshHayden Feb 7, 2020
1ff1da3
Updated constructor for Account
JoshHayden Feb 7, 2020
92059fb
Added freezeAccount tests
JoshHayden Feb 7, 2020
b0ed8b6
Freeze Account implemented, had to add a setter for frozen status in …
JoshHayden Feb 7, 2020
84a2ec4
Added unfreeze tests
JoshHayden Feb 7, 2020
24c2735
Implemented unfreeze
JoshHayden Feb 7, 2020
d7359ba
added withdraw tests
Blarfnip Feb 9, 2020
713e17d
implemented withdraw
Blarfnip Feb 9, 2020
1e20b7c
Merge pull request #4 from eostendarp/account-withdraw
Blarfnip Feb 9, 2020
a58ef55
added transfer tests
Blarfnip Feb 9, 2020
8e048e6
implemented account transfer
Blarfnip Feb 9, 2020
c88981e
Merge pull request #5 from eostendarp/account-transfer
Blarfnip Feb 9, 2020
9fb6dca
Added SavingsAccount withdraw tests
Blarfnip Feb 9, 2020
de63c5e
implemented SavingsAccount withdraw
Blarfnip Feb 9, 2020
8337317
Merge pull request #6 from eostendarp/savings-account-withdraw
Blarfnip Feb 9, 2020
c9bbd26
Added SavingsAccount calcInterest tests
Blarfnip Feb 9, 2020
cf22e06
implemented SavingsAccount calcInterest
Blarfnip Feb 9, 2020
1d22dd2
Merge pull request #7 from eostendarp/savings-account-calculateInterest
Blarfnip Feb 9, 2020
fef3647
added tests for User AddAccount, RemoveAccount, and getAccount
Blarfnip Feb 9, 2020
96aa90d
implemented getAccount, addAccount, and removeAccount
Blarfnip Feb 9, 2020
34bae5c
Merge pull request #8 from eostendarp/user-constructor-and-refactor
Blarfnip Feb 9, 2020
79d1d7e
added passing integration tests for User and Account
Blarfnip Feb 10, 2020
236c873
added usecase diagram to readme
Blarfnip Feb 10, 2020
36c6dd9
Merge pull request #9 from eostendarp/user-integration-test
Blarfnip Feb 10, 2020
d0e6eb9
Added AccountFrozenException and updated stubs
JoshHayden Feb 10, 2020
d9464a9
Updated withdrawTest to reflect AccountFrozenException
JoshHayden Feb 10, 2020
91fe4a4
Implemented frozen account in withdraw
JoshHayden Feb 10, 2020
21c89b1
Added account frozen to deposit tests
JoshHayden Feb 10, 2020
3f4fd0e
Implemented deposit with frozen accounts
JoshHayden Feb 10, 2020
07da95c
Added Account Frozen tests to AccountTest
JoshHayden Feb 10, 2020
2bbb8c8
Added Account Frozen tests to AccountTest
JoshHayden Feb 10, 2020
7da4fd4
Implemented transfer with AccountFrozenException
JoshHayden Feb 10, 2020
8a3d4d7
Refactored Admin to use CentralBank rather than a collection of Accounts
JoshHayden Feb 10, 2020
d29af73
Added calcTotalAssets tests
JoshHayden Feb 10, 2020
0fcd68f
Implemented calcTotalAssets
JoshHayden Feb 10, 2020
a45205f
Added integration test for Admin
JoshHayden Feb 10, 2020
27b3f9e
Added sequence diagram to readme
JoshHayden Feb 10, 2020
d21c6e9
removed redundant Teller method headers
Feb 11, 2020
d0ab882
paused to refactor CentralBank
Feb 11, 2020
30f9dd5
createAcountTest
Feb 11, 2020
4ece389
updating ATM
Feb 11, 2020
f744c1f
ATM now has CentralBank
Feb 11, 2020
494b1bc
Merge branch 'master' into add-account
Feb 11, 2020
fb27603
add Account
Feb 11, 2020
b042dd1
Added system test with admin, rounding issue right now that needs to …
JoshHayden Feb 11, 2020
d7cf46f
Fixed rounding error
JoshHayden Feb 11, 2020
3be9ec9
Added class diagram
JoshHayden Feb 11, 2020
cfe15d6
refactored to use map
Blarfnip Feb 11, 2020
217d5cf
Merge pull request #10 from eostendarp/centralBank-admin-refactor
Blarfnip Feb 11, 2020
f4ceb2c
Update README.md
eostendarp Feb 11, 2020
f69af25
removed depricated teller code
Feb 11, 2020
a67c52e
added createAccontTest
Feb 11, 2020
acb043a
added ATM tests and probably caused a bunch of merge conflicts
Blarfnip Feb 11, 2020
9078938
implemented createAccount
Feb 11, 2020
2fa4092
added central bank tests
Blarfnip Feb 11, 2020
eb7f0b3
added closeAccountTest
Feb 11, 2020
732274a
implemented closeAccount
Feb 11, 2020
21d50da
implemented ATM and CentralBank with basic tests
Blarfnip Feb 11, 2020
0ec444d
Merge branch 'master' of https://github.com/eostendarp/SoftwareEngine…
Blarfnip Feb 11, 2020
e6eaa56
Merge pull request #11 from eostendarp/atm-functionality
Blarfnip Feb 11, 2020
18de704
Refactored Admin's system test, labeled old system test as an integra…
JoshHayden Feb 11, 2020
4039fbc
Update README.md
eostendarp Feb 12, 2020
89fdec6
Update README.md
eostendarp Feb 12, 2020
140eaa0
Updated readme post code review
JoshHayden Feb 12, 2020
e7b9ade
Updated system test to include a third account and test for unfreezeA…
JoshHayden Feb 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
target/
.idea/
SoftwareEngineeringPractice.iml

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
Expand Down
13 changes: 0 additions & 13 deletions .idea/compiler.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/encodings.xml

This file was deleted.

17 changes: 0 additions & 17 deletions .idea/misc.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/sbt.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# SoftwareEngineeringPractice
## grading

To Do | correct
---|---
at least 8 commits|
isEmailValid|
withdraw|
isamountValid|
constructor & withdraw fix|

Use Case Diagram: https://www.lucidchart.com/invitations/accept/4307fa3a-0405-408d-ba36-95b8793790b6

Class Diagram: https://www.draw.io/#G14lOqCFtOO7uEm51Zpj4FGR7ti2bjM54R

Sequence Diagram (Saul): Teller, User, Account https://drive.google.com/file/d/1OXqnUsb1rqihpPv-qyBwDjLqungH4SJd/view?usp=sharing

Sequence Diagram (Josh): Admin, Account, CentralBank https://drive.google.com/file/d/1hWu4E4gvjYxcYmPHV18QAMbwkdUuo9Hd/view?usp=sharing

Sequence Diagram (Erich): https://drive.google.com/file/d/1tcE_ITNZHlpZ7IzYDILuwuuKqsxNMex5/view?usp=sharing

Code Review Notes: Need to update class diagram to no longer have user. Update use case diagram to be more readable.
Generally we want to update tests, Josh will update Admin system test to test for more than two accounts. Saul will make sure method names match the diagram. Eric will update some other tests.
2 changes: 0 additions & 2 deletions SoftwareEngineeringPractice.iml

This file was deleted.

45 changes: 45 additions & 0 deletions src/main/java/edu/ithaca/dragon/bank/ATM.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package edu.ithaca.dragon.bank;

public class ATM implements BasicAPI {

protected CentralBank centralBank;

public ATM(CentralBank bank) {
centralBank = bank;
}

@Override
public boolean confirmCredentials(String acctId, String password) {
return false;
}

@Override
public double checkBalance(String acctId) {

return centralBank.checkBalance(acctId);
}

@Override
public void withdraw(String acctId, double amount) throws AccountFrozenException, InsufficientFundsException {
centralBank.withdraw(acctId, amount);
}

@Override
public void deposit(String acctId, double amount) throws AccountFrozenException {
centralBank.deposit(acctId, amount);
}

@Override
public void transfer(String acctIdToWithdrawFrom, String acctIdToDepositTo, double amount) throws InsufficientFundsException, AccountFrozenException {
centralBank.transfer(acctIdToWithdrawFrom, acctIdToDepositTo, amount);
}

@Override
public String transactionHistory(String acctId) {
return null;
}

public CentralBank getCentralBank() {
return centralBank;
}
}
117 changes: 117 additions & 0 deletions src/main/java/edu/ithaca/dragon/bank/Account.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package edu.ithaca.dragon.bank;

import java.util.Collection;
import java.util.regex.Pattern;

public abstract class Account {
protected double balance;
protected boolean isFrozen;
protected Collection<User> users;
protected String id;


public Account(double startingBalance, String id) {
if (!isAmountValid(startingBalance)) {
throw new IllegalArgumentException("Starting balance: " + startingBalance + " is invalid, cannot create account");
}
else if (id.equals("")){
throw new IllegalArgumentException("ID cannot be an empty string");
}
else {
this.balance = startingBalance;
this.isFrozen = false;
this.id = id;
}
}

/**
* reduces the balance by amount if amount is non-negative, has 2 or fewer decimals and is smaller or equal to balance
* @param amount quantity to reduce balance by
* @throws IllegalArgumentException if amount is negative or has more than 2 decimals
* @throws InsufficientFundsException if amount is larger than balance
*/
public void withdraw(double amount) throws InsufficientFundsException, AccountFrozenException{
if (isFrozen){
throw new AccountFrozenException("Account is frozen");
}
else if (!isAmountValid(amount)) {
throw new IllegalArgumentException("Amount: " + amount + " is invalid, cannot withdraw");
} else if (amount > balance) {
throw new InsufficientFundsException("Not enough money");
} else {
balance -= amount;
}
}

/**
* increases the balance by amount if non-negative and has 2 or fewer decimals
* @param amount quantity to increase balance by
* @throws IllegalArgumentException if amount is negative or has more than 2 decimal places
*/
public void deposit(double amount) throws AccountFrozenException{
if (isFrozen){
throw new AccountFrozenException("Account is frozen");
}
else if (!isAmountValid(amount)) {
throw new IllegalArgumentException("Amount: " + amount + " is invalid, cannot deposit");
} else {
balance += amount;
}
}

/**
* withdraws amount from balance and deposits it into to's balance
* @param toAccount BankAccount who's balance will be deposited into
* @param amount quantity to withdraw from balance and deposit into to's balance
* @throws IllegalArgumentException if amount is negative or has more than 2 decimals
* @throws InsufficientFundsException if amount is larger than balance
*/
public void transfer(Account toAccount, double amount) throws InsufficientFundsException, AccountFrozenException {
if (this.isFrozen || toAccount.isFrozen){
throw new AccountFrozenException("Account is frozen");
}
else if (!isAmountValid(amount)) {
throw new IllegalArgumentException("Amount: " + amount + " is invalid, cannot transfer");
} else if (amount > balance) {
throw new InsufficientFundsException("Not enough money");
} else {
withdraw(amount);
toAccount.deposit(amount);
}
}

public String getCredentials() {
return "";
}

public double getBalance() {
return balance;
}

public String getHistory() {
return "";
}

public boolean getFrozenStatus(){
return isFrozen;
}

public void setFrozen(boolean frozenStatus){
isFrozen = frozenStatus;
}

public String getID(){
return id;
}

/**
* returns true if the amount is non-negative and has two decimal points or less, and false otherwise
* @param amount quantity to check
* @return true if the amount is non-negative and has two decimal points or less, and false otherwise
*/
public static boolean isAmountValid(double amount) {
String amountStr = String.valueOf(amount);
int charsAfterDec = amountStr.length() - amountStr.indexOf('.') - 1;
return amount >= 0 && charsAfterDec <= 2;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package edu.ithaca.dragon.bank;

public class AccountFrozenException extends Exception{

public AccountFrozenException(String s){
super(s);
}

}
63 changes: 63 additions & 0 deletions src/main/java/edu/ithaca/dragon/bank/Admin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package edu.ithaca.dragon.bank;

import java.util.Collection;
import java.util.Iterator;
import java.math.RoundingMode;
import java.text.DecimalFormat;



public class Admin implements AdminAPI {
private static DecimalFormat twoDecimals = new DecimalFormat("0.00");
CentralBank bank;


/**
* creates an Admin account that knows what accounts it controls
* @param bank the CentralBank that Admin must act on
*/
public Admin(CentralBank bank){
this.bank = bank;
}

@Override
public double calcTotalAssets() {
double total = 0;
Iterator<Account> itr = this.bank.getAccounts().values().iterator();
while (itr.hasNext()){
Account current = itr.next();
total += current.getBalance();
}
total = Double.valueOf(twoDecimals.format(total));

return total;
}

@Override
public Collection<String> findAcctIdsWithSuspiciousActivity() {
return null;
}

@Override
public void freezeAccount(String acctId) throws IllegalArgumentException {
setAcctFreezeStatus(acctId,true);
}

@Override
public void unfreezeAcct(String acctId) throws IllegalArgumentException {
setAcctFreezeStatus(acctId,false);
}

public void setAcctFreezeStatus(String acctId, boolean isFrozen) {
boolean accountFound = (bank.getAccounts().containsKey(acctId));
if(accountFound) {
bank.getAccounts().get(acctId).setFrozen(isFrozen);
} else {
throw new IllegalArgumentException("String not in collection");
}
}

public CentralBank getBank(){
return this.bank;
}
}
15 changes: 15 additions & 0 deletions src/main/java/edu/ithaca/dragon/bank/AdminAPI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package edu.ithaca.dragon.bank;

import java.util.Collection;

public interface AdminAPI {

public double calcTotalAssets();

public Collection<String> findAcctIdsWithSuspiciousActivity();

public void freezeAccount(String acctId);

public void unfreezeAcct(String acctId);

}
9 changes: 9 additions & 0 deletions src/main/java/edu/ithaca/dragon/bank/AdvancedAPI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package edu.ithaca.dragon.bank;

//API to be used by Teller systems
public interface AdvancedAPI extends BasicAPI {

public void createAccount(String acctId, double startingBalance);

public void closeAccount(String acctId);
}
Loading