From 57b481e54b71fbe023ebd7810e682925143ad675 Mon Sep 17 00:00:00 2001 From: John Squier Date: Tue, 17 Jan 2017 13:10:11 -0500 Subject: [PATCH 1/6] Initial commit --- .gitignore | 1 + Access_Control_Lab.md | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 .gitignore create mode 100755 Access_Control_Lab.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/Access_Control_Lab.md b/Access_Control_Lab.md new file mode 100755 index 0000000..f290a1a --- /dev/null +++ b/Access_Control_Lab.md @@ -0,0 +1,41 @@ +# Access Control Lab - Bank Account + +## Description + +This lab focuses on implementing a simulated bank account and practicing using access control features of the Java language. By the end of this lab students should feel comfortable setting class members to be private or public, creating accessor and mutator functions for fields as needed, and using those methods to access the underlying fields. + +The bank account functionality produced in this lab will be integrated into the weekly project and may be further enhanced during the project. + +## Testing + +All features should be developed following a Test-Driven Development methodology. All features should be thoroughly tested and demonstrated through unit tests. + +## Instructions + +Create a class for bank accounts. + +Accounts must have: + +- Account type (Checking, Savings, Investment, etc.) +- Account number (Must be unique for each account created) +- Balance +- Account Holder's name +- Interest rate (some accounts may not draw interest) +- Status (Open, Closed, [OFAC](https://www.treasury.gov/about/organizational-structure/offices/Pages/Office-of-Foreign-Assets-Control.aspx) Freeze...) +- Overdraft prevention (enabled, disabled, or automatic account transfer*) +- A record of all transactions that have taken place on the accounts (withdrawals, deposits, transfers, and changes to the status, name, or interest rate) + + +Code that uses the Account class should not be able to change the properties of an account directly; this should be something handled by methods provided by the account class. The methods should enforce the following behavior: + +- Account type and account number must be set during account creation (in the constructor) and cannot be changed afterward. +- Balance inquiries are allowed at any time except while an account is under an OFAC freeze +- The balance can be changed with a credit (add money) or debit (remove money) + - Balance changes can only occur on `Open` accounts. + - The `debit` and `credit` methods should return an approval status indicating whether the transaction was approved. + - 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. +- Account holder's name must be set during account creation. It can be changed later (but not on closed accounts) +- Accounts with overdraft prevention enabled cannot over-draw (a debit that is greater than the account balance will be declined and the balance will not change) +- Accounts, once closed, cannot be reopened (frozen accounts can be unfrozen). + - No changes to the balance of an account can take place while it is closed or frozen + - Accounts must have a zero balance before they can be closed. \ No newline at end of file From 7a34ba624ea3bf02ac2313e18f93bbe5961a8404 Mon Sep 17 00:00:00 2001 From: John Squier Date: Tue, 17 Jan 2017 14:01:36 -0500 Subject: [PATCH 2/6] Began filling out classes --- .idea/.name | 1 + .idea/compiler.xml | 16 + .idea/libraries/Maven__junit_junit_4_12.xml | 13 + .../Maven__org_hamcrest_hamcrest_core_1_3.xml | 13 + .idea/misc.xml | 13 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + .idea/workspace.xml | 730 ++++++++++++++++++ AccessControl.iml | 17 + pom.xml | 34 + .../john/accessControl/BankAccount.java | 16 + .../john/accessControl/BankAccountStatus.java | 6 + .../john/accessControl/BankAccountType.java | 7 + .../accessControl/OverdraftProtection.java | 6 + .../john/accessControl/BankAccountTest.java | 20 + 15 files changed, 906 insertions(+) create mode 100644 .idea/.name create mode 100644 .idea/compiler.xml create mode 100644 .idea/libraries/Maven__junit_junit_4_12.xml create mode 100644 .idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 AccessControl.iml create mode 100644 pom.xml create mode 100644 src/main/java/squier/john/accessControl/BankAccount.java create mode 100644 src/main/java/squier/john/accessControl/BankAccountStatus.java create mode 100644 src/main/java/squier/john/accessControl/BankAccountType.java create mode 100644 src/main/java/squier/john/accessControl/OverdraftProtection.java create mode 100644 src/test/java/squier/john/accessControl/BankAccountTest.java diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..2a1782b --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +AccessControlLab \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..1c66e39 --- /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..d0f80ed --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ 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..8b97037 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,730 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1484677864162 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AccessControl.iml b/AccessControl.iml new file mode 100644 index 0000000..5cf6df2 --- /dev/null +++ b/AccessControl.iml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..6775867 --- /dev/null +++ b/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + squier.john + AccessControlLab + 1.0-SNAPSHOT + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + + + junit + junit + 4.12 + + + + \ No newline at end of file diff --git a/src/main/java/squier/john/accessControl/BankAccount.java b/src/main/java/squier/john/accessControl/BankAccount.java new file mode 100644 index 0000000..d4864a3 --- /dev/null +++ b/src/main/java/squier/john/accessControl/BankAccount.java @@ -0,0 +1,16 @@ +package squier.john.accessControl; + +/** + * Created by johnsquier on 1/17/17. + */ +public class BankAccount { + + private BankAccountType accountType; + private int accountNumber; + private static int nextAccoutNumber = 1; + private double balance; + private String accountHoldersName; + private double interestRate; + private BankAccountStatus accountStatus; + +} diff --git a/src/main/java/squier/john/accessControl/BankAccountStatus.java b/src/main/java/squier/john/accessControl/BankAccountStatus.java new file mode 100644 index 0000000..72afbb2 --- /dev/null +++ b/src/main/java/squier/john/accessControl/BankAccountStatus.java @@ -0,0 +1,6 @@ +package squier.john.accessControl; + +/** + * Created by johnsquier on 1/17/17. + */ +public enum BankAccountStatus {OPEN, CLOSED, OFAC_FROZEN;} \ No newline at end of file diff --git a/src/main/java/squier/john/accessControl/BankAccountType.java b/src/main/java/squier/john/accessControl/BankAccountType.java new file mode 100644 index 0000000..9eef353 --- /dev/null +++ b/src/main/java/squier/john/accessControl/BankAccountType.java @@ -0,0 +1,7 @@ +package squier.john.accessControl; + +/** + * Created by johnsquier on 1/17/17. + */ +public enum BankAccountType { CHECKING, SAVINGS, INVESTMENT; } + diff --git a/src/main/java/squier/john/accessControl/OverdraftProtection.java b/src/main/java/squier/john/accessControl/OverdraftProtection.java new file mode 100644 index 0000000..da3a19b --- /dev/null +++ b/src/main/java/squier/john/accessControl/OverdraftProtection.java @@ -0,0 +1,6 @@ +package squier.john.accessControl; + +/** + * Created by johnsquier on 1/17/17. + */ +public enum OverdraftProtection {ENABLED, DISABLED, AUTOMATIC_ACCT_TRANSFER;} diff --git a/src/test/java/squier/john/accessControl/BankAccountTest.java b/src/test/java/squier/john/accessControl/BankAccountTest.java new file mode 100644 index 0000000..79f6c91 --- /dev/null +++ b/src/test/java/squier/john/accessControl/BankAccountTest.java @@ -0,0 +1,20 @@ +package squier.john.accessControl; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * Created by johnsquier on 1/17/17. + */ +public class BankAccountTest { + + BankAccount bankAccount; + + @Before + bankAccount = new BankAccount(); + + @Test + + +} From 03582a28ee837e4d7e582d8b00b55aa9dbfe3f8f Mon Sep 17 00:00:00 2001 From: John Squier Date: Tue, 17 Jan 2017 14:12:17 -0500 Subject: [PATCH 3/6] continued expanding classes --- .idea/workspace.xml | 62 +++++++++++++++---- .../john/accessControl/BankAccount.java | 5 ++ .../accessControl/BankAccountTransaction.java | 19 ++++++ .../john/accessControl/TransactionType.java | 7 +++ 4 files changed, 82 insertions(+), 11 deletions(-) create mode 100644 src/main/java/squier/john/accessControl/BankAccountTransaction.java create mode 100644 src/main/java/squier/john/accessControl/TransactionType.java diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 8b97037..8156ba4 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,9 @@ - + + + @@ -624,12 +648,12 @@