diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..8229acc Binary files /dev/null and b/.DS_Store differ diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..1fc16a8 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +AccessControl \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..577caa2 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__junit_junit_4_12.xml b/.idea/libraries/Maven__junit_junit_4_12.xml new file mode 100644 index 0000000..d411041 --- /dev/null +++ b/.idea/libraries/Maven__junit_junit_4_12.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml new file mode 100644 index 0000000..f58bbc1 --- /dev/null +++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..5755a99 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..767d9ff --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..33dcf61 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,1083 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + project + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1484686509620 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Access_Control_Lab.iml b/Access_Control_Lab.iml new file mode 100644 index 0000000..03320bd --- /dev/null +++ b/Access_Control_Lab.iml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Bank AccountUML.pdf b/Bank AccountUML.pdf new file mode 100644 index 0000000..5a49650 Binary files /dev/null and b/Bank AccountUML.pdf differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..30201a0 --- /dev/null +++ b/pom.xml @@ -0,0 +1,22 @@ + + + 4.0.0 + + reynoldstitko.gillian + AccessControl + 1.0-SNAPSHOT + + + + + junit + junit + 4.12 + + + + + + \ No newline at end of file diff --git a/src/main/java/reynoldstitko/gillian/AccountStatus.java b/src/main/java/reynoldstitko/gillian/AccountStatus.java new file mode 100644 index 0000000..b40881e --- /dev/null +++ b/src/main/java/reynoldstitko/gillian/AccountStatus.java @@ -0,0 +1,29 @@ +package reynoldstitko.gillian; + +/** + * Created by gillianreynolds-titko on 1/17/17. + */ +//public class AccountStatus { +// //private enum OverdraftStatus {ENABLED, DISABLED, ATF}; //define the enum +// //protected enum StatusType {OPEN, CLOSED, OFAC}; +// private OverdraftStatus overdraftStatus; //Create a field of type OverdraftStatus +// private StatusType statusType; +// +// +// public StatusType getStatusType(){ +// return statusType; +// } +// +// public void setStatusType(StatusType statusType){ +// this.statusType = statusType; +// } +// +// public void setOverdraftStatus(OverdraftStatus overdraftStatus){ +// this.overdraftStatus = overdraftStatus; +// } +// +// public OverdraftStatus getOverdraftStatus(){ +// return overdraftStatus; +// } +// +//} diff --git a/src/main/java/reynoldstitko/gillian/AccountType.java b/src/main/java/reynoldstitko/gillian/AccountType.java new file mode 100644 index 0000000..89a1796 --- /dev/null +++ b/src/main/java/reynoldstitko/gillian/AccountType.java @@ -0,0 +1,10 @@ +package reynoldstitko.gillian; + +/** + * Created by gillianreynolds-titko on 1/17/17. + */ +public enum AccountType { + CHECKING, + SAVINGS, + INVESTMENT; +} diff --git a/src/main/java/reynoldstitko/gillian/BankManager.java b/src/main/java/reynoldstitko/gillian/BankManager.java new file mode 100644 index 0000000..8b5e524 --- /dev/null +++ b/src/main/java/reynoldstitko/gillian/BankManager.java @@ -0,0 +1,38 @@ +package reynoldstitko.gillian; + +/** + * Created by gillianreynolds-titko on 1/17/17. + */ +public class BankManager { + + //private enum AccountType { CHECKING, SAVINGS, INVESTMENT} + private AccountType accountType; + public static Double getAccountNumber() { + + return accountNumber; + } + + //BankManager(){}; + + private static Double accountNumber = 12345678d; + private CustomerAccount account = new CustomerAccount(); + + //Create a constructor; include account number, account type and account name + public BankManager(AccountType accountType, String customerName){ + accountNumber = accountNumber + 1; //Set the account number + this.accountType = accountType; + account.setAccountHolderName(customerName); + } + + public void openAccount(AccountType accountType, String customerName){ + BankManager account = new BankManager(accountType, customerName); + } + + public void closeAccount(Double accountNumber){ + //Account balance must be zero before it can be closed + if(account.getAccountBalance() == 0.0){ + accountNumber = 0.0; + } + } + +} diff --git a/src/main/java/reynoldstitko/gillian/CustomerAccount.java b/src/main/java/reynoldstitko/gillian/CustomerAccount.java new file mode 100644 index 0000000..71bc761 --- /dev/null +++ b/src/main/java/reynoldstitko/gillian/CustomerAccount.java @@ -0,0 +1,80 @@ +package reynoldstitko.gillian; + +import static java.lang.System.out; + +/** + * Created by gillianreynolds-titko on 1/17/17. + */ +public class CustomerAccount { + private Double accountBalance; + private String accountHolderName; + + private StatusType accountStatus; + //private OverdraftStatus overdraftStatus = new OverdraftStatus(); + //private StatusType statusType = new StatusType(); + + + public String getAccountHolderName(){ + return accountHolderName; + } + + public void setAccountHolderName(String customerName){ + accountHolderName = customerName; + } + + //Balance inquiries are allowed at any time except while an account + // is under an OFAC freeze (status) + public Double getAccountBalance(){ + if(!getAccountStatus().equals(StatusType.OFAC)) + return accountBalance; + else { + System.out.println("Your account is frozen"); + return null; + } + } + + public void setAccountBalance(Double accountBalance){ + this.accountBalance = accountBalance; + } + + public String debit(Double reduceByAmount){ + accountBalance = accountBalance - reduceByAmount; + return "Account debited successfully"; + + } + + public String credit(Double increaseByAmount){ + accountBalance = accountBalance + increaseByAmount; + return "Account credited successfully"; + + } + + //Accounts can transfer funds to or from another account with the same account holder + // ‐‐ Neither account's balance should fall below zero as a result of a transfer. + public String transferFunds(CustomerAccount fromCustomerAccount, CustomerAccount toCustomerAccount, + Double amountToTransfer){ + String sourceName = fromCustomerAccount.getAccountHolderName(); + String destinationName = toCustomerAccount.getAccountHolderName(); + if(sourceName.equals(destinationName) && (fromCustomerAccount.accountStatus.equals(StatusType.OPEN)) + && (toCustomerAccount.accountStatus.equals(StatusType.OPEN)) && + fromCustomerAccount.accountBalance >= amountToTransfer) + { + fromCustomerAccount.debit(amountToTransfer); + toCustomerAccount.credit(amountToTransfer); + return "Transfer successful"; + } + return "Transfer not successful"; + } + + public void setAccountStatus(StatusType accountStatus) { + + this.accountStatus = accountStatus; + } + + public StatusType getAccountStatus() { + + return accountStatus; + } + + +} diff --git a/src/main/java/reynoldstitko/gillian/OverdraftStatus.java b/src/main/java/reynoldstitko/gillian/OverdraftStatus.java new file mode 100644 index 0000000..abdf444 --- /dev/null +++ b/src/main/java/reynoldstitko/gillian/OverdraftStatus.java @@ -0,0 +1,14 @@ +package reynoldstitko.gillian; + +/** + * Created by gillianreynolds-titko on 1/17/17. + */ + +public enum OverdraftStatus { + ENABLED, + DISABLED, + ATF; + + //Don't need a getter or setter in an enum + +} diff --git a/src/main/java/reynoldstitko/gillian/StatusType.java b/src/main/java/reynoldstitko/gillian/StatusType.java new file mode 100644 index 0000000..9a3deee --- /dev/null +++ b/src/main/java/reynoldstitko/gillian/StatusType.java @@ -0,0 +1,14 @@ +package reynoldstitko.gillian; + +/** + * Created by gillianreynolds-titko on 1/17/17. + */ +public enum StatusType { + + OPEN, + CLOSED, + OFAC; + + //Don't need a getter or setter in an enum + +} diff --git a/src/test/java/reynoldsgillian/titko/BankManagerTest.java b/src/test/java/reynoldsgillian/titko/BankManagerTest.java new file mode 100644 index 0000000..d27aa71 --- /dev/null +++ b/src/test/java/reynoldsgillian/titko/BankManagerTest.java @@ -0,0 +1,25 @@ +package reynoldsgillian.titko; + +import org.junit.Test; +import reynoldstitko.gillian.AccountType; +import reynoldstitko.gillian.BankManager; + +/** + * Created by gillianreynolds-titko on 1/17/17. + */ +public class BankManagerTest { + + BankManager bankManager = new BankManager(AccountType.CHECKING, "Jane Doe"); + + + @Test + public void BankManagerTest(){ + + } + + @Test + public void closeAccountTest(){ + Double expected = 0.0; + + } +} diff --git a/src/test/java/reynoldsgillian/titko/CustomerAccountTest.java b/src/test/java/reynoldsgillian/titko/CustomerAccountTest.java new file mode 100644 index 0000000..e6ef673 --- /dev/null +++ b/src/test/java/reynoldsgillian/titko/CustomerAccountTest.java @@ -0,0 +1,144 @@ +package reynoldsgillian.titko; + +import org.junit.Test; +//import reynoldstitko.gillian.AccountStatus; +import reynoldstitko.gillian.CustomerAccount; +import reynoldstitko.gillian.StatusType; + +import static junit.framework.TestCase.assertEquals; + +/** + * Created by gillianreynolds-titko on 1/17/17. + */ +public class CustomerAccountTest { + + CustomerAccount customerAccount = new CustomerAccount(); + CustomerAccount customerAccount2 = new CustomerAccount(); + + + @Test + public void getAccountHolderNameTest(){ + String expected = "Gillian"; + customerAccount.setAccountHolderName("Gillian"); + String actual = customerAccount.getAccountHolderName(); + assertEquals("I expected Gillian", expected, actual); + } + + @Test + public void setAccountHolderNameTest(){ + String expected = "Jane Doe"; + customerAccount.setAccountHolderName("Jane Doe"); + String actual = customerAccount.getAccountHolderName(); + assertEquals("I expected Jane Doe", expected, actual); + } + + @Test + public void getAccountBalanceTest(){ + Double expected = 10.0; + customerAccount.setAccountBalance(10.0); + customerAccount.setAccountStatus(StatusType.OPEN); + Double actual = customerAccount.getAccountBalance(); + assertEquals("Exepected 10", expected, actual); + } + + @Test + public void getAccountBalanceTestFrozen(){ + Double expected = null; + customerAccount.setAccountBalance(10.0); + customerAccount.setAccountStatus(StatusType.OFAC); + Double actual = customerAccount.getAccountBalance(); + assertEquals("Expected null", expected, actual); + } + + @Test + public void setAccountBalanceTest(){ + Double expected = 15.0; + customerAccount.setAccountBalance(15.0); + customerAccount.setAccountStatus(StatusType.OPEN); + Double actual = customerAccount.getAccountBalance(); + assertEquals("I expected 15.0", expected, actual); + } + + @Test + public void getAccountStatusTestOpen(){ + StatusType expected = StatusType.OPEN; + customerAccount.setAccountStatus(StatusType.OPEN); + StatusType actual = customerAccount.getAccountStatus(); + assertEquals("I expected OPEN", expected, actual); + } + + @Test + public void getAccountStatusTestClosed(){ + StatusType expected = StatusType.CLOSED; + customerAccount.setAccountStatus(StatusType.CLOSED); + StatusType actual = customerAccount.getAccountStatus(); + assertEquals("I expected CLOSED", expected, actual); + } + + @Test + public void getAccountStatusTestOFAC(){ + StatusType expected = StatusType.OFAC; + customerAccount.setAccountStatus(StatusType.OFAC); + StatusType actual = customerAccount.getAccountStatus(); + assertEquals("I expected OFAC", expected, actual); + } + + @Test + public void transferFundsTest(){ + customerAccount.setAccountStatus(StatusType.OPEN); + customerAccount2.setAccountStatus(StatusType.OPEN); + customerAccount.setAccountHolderName("Ted"); + customerAccount2.setAccountHolderName("Ted"); + customerAccount.setAccountBalance(20.0); + customerAccount2.setAccountBalance(100.0); + String expected = "Transfer successful"; + String actual = customerAccount.transferFunds(customerAccount2, customerAccount, 5.0); + assertEquals("I expected success", expected, actual); + } + + @Test + public void transferFundsFail1Test(){ + customerAccount.setAccountStatus(StatusType.OPEN); + customerAccount2.setAccountStatus(StatusType.OPEN); + customerAccount.setAccountHolderName("Tom"); + customerAccount2.setAccountHolderName("Ted"); + customerAccount.setAccountBalance(20.0); + customerAccount2.setAccountBalance(100.0); + String expected = "Transfer not successful"; + String actual = customerAccount.transferFunds(customerAccount2, customerAccount, 5.0); + assertEquals("I expected not successful", expected, actual); + } + + @Test + public void transferFundsFail2Test(){ + customerAccount.setAccountStatus(StatusType.CLOSED); + customerAccount2.setAccountStatus(StatusType.OPEN); + customerAccount.setAccountHolderName("Tom"); + customerAccount2.setAccountHolderName("Ted"); + customerAccount.setAccountBalance(20.0); + customerAccount2.setAccountBalance(100.0); + String expected = "Transfer not successful"; + String actual = customerAccount.transferFunds(customerAccount2, customerAccount, 5.0); + assertEquals("I expected not successful", expected, actual); + } + + @Test + public void debitTest(){ + String expected = "Account debited successfully"; + customerAccount.setAccountBalance(100.0); + customerAccount.setAccountStatus(StatusType.OPEN); + String actual = customerAccount.debit(50.0); + assertEquals("I expected account debited successfully", expected, actual); + } + + @Test + public void creditTest(){ + String expected = "Account credited successfully"; + customerAccount.setAccountBalance(100.0); + customerAccount.setAccountStatus(StatusType.OPEN); + String actual = customerAccount.credit(50.0); + assertEquals("I expected account debited successfully", expected, actual); + } + + +} diff --git a/target/classes/reynoldstitko/gillian/AccountType.class b/target/classes/reynoldstitko/gillian/AccountType.class new file mode 100644 index 0000000..b84160e Binary files /dev/null and b/target/classes/reynoldstitko/gillian/AccountType.class differ diff --git a/target/classes/reynoldstitko/gillian/BankManager.class b/target/classes/reynoldstitko/gillian/BankManager.class new file mode 100644 index 0000000..dc01f40 Binary files /dev/null and b/target/classes/reynoldstitko/gillian/BankManager.class differ diff --git a/target/classes/reynoldstitko/gillian/CustomerAccount.class b/target/classes/reynoldstitko/gillian/CustomerAccount.class new file mode 100644 index 0000000..c1919b3 Binary files /dev/null and b/target/classes/reynoldstitko/gillian/CustomerAccount.class differ diff --git a/target/classes/reynoldstitko/gillian/OverdraftStatus.class b/target/classes/reynoldstitko/gillian/OverdraftStatus.class new file mode 100644 index 0000000..fddeca3 Binary files /dev/null and b/target/classes/reynoldstitko/gillian/OverdraftStatus.class differ diff --git a/target/classes/reynoldstitko/gillian/StatusType.class b/target/classes/reynoldstitko/gillian/StatusType.class new file mode 100644 index 0000000..af885b5 Binary files /dev/null and b/target/classes/reynoldstitko/gillian/StatusType.class differ diff --git a/target/test-classes/reynoldsgillian/titko/BankManagerTest.class b/target/test-classes/reynoldsgillian/titko/BankManagerTest.class new file mode 100644 index 0000000..0f6ca64 Binary files /dev/null and b/target/test-classes/reynoldsgillian/titko/BankManagerTest.class differ diff --git a/target/test-classes/reynoldsgillian/titko/CustomerAccountTest.class b/target/test-classes/reynoldsgillian/titko/CustomerAccountTest.class new file mode 100644 index 0000000..ac1f318 Binary files /dev/null and b/target/test-classes/reynoldsgillian/titko/CustomerAccountTest.class differ