+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ 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/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
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/ApprovalStatus.java b/src/main/java/squier/john/accessControl/ApprovalStatus.java
new file mode 100644
index 0000000..391c8c4
--- /dev/null
+++ b/src/main/java/squier/john/accessControl/ApprovalStatus.java
@@ -0,0 +1,6 @@
+package squier.john.accessControl;
+
+/**
+ * Created by johnsquier on 1/17/17.
+ */
+public enum ApprovalStatus {APPROVED, NOT_APPROVED, ZERO_TRANSACTION;}
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..2ddd6ca
--- /dev/null
+++ b/src/main/java/squier/john/accessControl/BankAccount.java
@@ -0,0 +1,60 @@
+package squier.john.accessControl;
+
+import java.util.ArrayList;
+
+/**
+ * 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;
+ private OverdraftProtection overdraftProtection;
+ private ArrayList transactionRecord;
+
+ public BankAccount(BankAccountType accountType, double balance, String accountHoldersName, double interestRate,
+ BankAccountStatus accountStatus, OverdraftProtection overdraftProtection) {
+ this.accountType = accountType;
+ accountNumber = nextAccoutNumber++;
+ this.balance = balance;
+ this.accountHoldersName = accountHoldersName;
+ this.interestRate = interestRate;
+ this.accountStatus = accountStatus;
+ this.overdraftProtection = overdraftProtection;
+ transactionRecord = new ArrayList();
+ }
+
+ public Double getBalance() {
+ if ( accountStatus.equals(BankAccountStatus.OFAC_FROZEN) ) {
+ // do nothing probably throw an expection at some point
+ return null;
+ }
+ else {
+ return balance;
+ }
+ }
+
+ public ApprovalStatus updateBalanceWithCreditOrDebit(double amount) {
+ if ( accountStatus.equals(BankAccountStatus.OPEN) ) {
+ if ( amount > 0.0 ) {
+ credit(amount);
+ }
+ else {
+ debit(amount);
+ }
+ }
+ }
+
+ private ApprovalStatus credit(double amount) {
+
+ }
+
+ private ApprovalStatus debit(double amount) {
+
+ }
+}
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/BankAccountTransaction.java b/src/main/java/squier/john/accessControl/BankAccountTransaction.java
new file mode 100644
index 0000000..eb0b243
--- /dev/null
+++ b/src/main/java/squier/john/accessControl/BankAccountTransaction.java
@@ -0,0 +1,19 @@
+package squier.john.accessControl;
+
+/**
+ * Created by johnsquier on 1/17/17.
+ */
+public class BankAccountTransaction {
+ private TransactionType transactionType;
+ private double transactionAmount;
+ private BankAccountStatus newStatus;
+ private String newName;
+
+ public BankAccountTransaction(TransactionType transactionType, double transactionAmount,
+ BankAccountStatus newStatus, String newName) {
+ this.transactionType = transactionType;
+ this.transactionAmount = transactionAmount;
+ this.newStatus = newStatus;
+ this.newName = newName;
+ }
+}
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/main/java/squier/john/accessControl/TransactionType.java b/src/main/java/squier/john/accessControl/TransactionType.java
new file mode 100644
index 0000000..06a4061
--- /dev/null
+++ b/src/main/java/squier/john/accessControl/TransactionType.java
@@ -0,0 +1,7 @@
+package squier.john.accessControl;
+
+/**
+ * Created by johnsquier on 1/17/17.
+ */
+public enum TransactionType {WITHDRAWL, DEPOSIT, TRANSFER, STATUS_CHANGE, NAME_CHANGE, INTEREST_RATE_CHANGE;}
+
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..8967c33
--- /dev/null
+++ b/src/test/java/squier/john/accessControl/BankAccountTest.java
@@ -0,0 +1,57 @@
+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;
+ double delta = 0.00001;
+
+ @Test
+ public void getBalanceAccountUnfrozenTest() {
+ bankAccount = new BankAccount(BankAccountType.SAVINGS, 100.0,
+ "John", 10.0, BankAccountStatus.OPEN,
+ OverdraftProtection.ENABLED);
+
+ Double expected = 100.0;
+ Double actual = bankAccount.getBalance();
+ Assert.assertEquals(expected, actual, delta);
+ }
+
+ @Test
+ public void getBalanceAccountFrozenTest() {
+ bankAccount = new BankAccount(BankAccountType.SAVINGS, 100.0,
+ "John", 10.0, BankAccountStatus.OFAC_FROZEN,
+ OverdraftProtection.ENABLED);
+ Double expected = null;
+ Double actual = bankAccount.getBalance();
+ Assert.assertEquals(expected, actual, delta);
+ }
+
+ @Test
+ public void updateBalanceAccountClosedTest() {
+ bankAccount = new BankAccount(BankAccountType.SAVINGS, 100.0,
+ "John", 10.0, BankAccountStatus.OPEN,
+ OverdraftProtection.ENABLED);
+ Double expected = 100.0;
+ bankAccount.updateBalanceWithCreditOrDebit(5.0);
+ Double actual = bankAccount.getBalance();
+ }
+
+ @Test
+ public void updateBalancePositiveTest() {
+ bankAccount = new BankAccount(BankAccountType.SAVINGS, 100.0,
+ "John", 10.0, BankAccountStatus.OPEN,
+ OverdraftProtection.ENABLED);
+ Double expected = 200.0;
+ bankAccount.updateBalanceWithCreditOrDebit(100.0);
+ Double actual = bankAccount.getBalance();
+ }
+
+}
diff --git a/target/classes/squier/john/accessControl/BankAccount.class b/target/classes/squier/john/accessControl/BankAccount.class
new file mode 100644
index 0000000..57af82f
Binary files /dev/null and b/target/classes/squier/john/accessControl/BankAccount.class differ
diff --git a/target/classes/squier/john/accessControl/BankAccountStatus.class b/target/classes/squier/john/accessControl/BankAccountStatus.class
new file mode 100644
index 0000000..972df03
Binary files /dev/null and b/target/classes/squier/john/accessControl/BankAccountStatus.class differ
diff --git a/target/classes/squier/john/accessControl/BankAccountTransaction.class b/target/classes/squier/john/accessControl/BankAccountTransaction.class
new file mode 100644
index 0000000..796b764
Binary files /dev/null and b/target/classes/squier/john/accessControl/BankAccountTransaction.class differ
diff --git a/target/classes/squier/john/accessControl/BankAccountType.class b/target/classes/squier/john/accessControl/BankAccountType.class
new file mode 100644
index 0000000..cdfe5b3
Binary files /dev/null and b/target/classes/squier/john/accessControl/BankAccountType.class differ
diff --git a/target/classes/squier/john/accessControl/OverdraftProtection.class b/target/classes/squier/john/accessControl/OverdraftProtection.class
new file mode 100644
index 0000000..799a802
Binary files /dev/null and b/target/classes/squier/john/accessControl/OverdraftProtection.class differ
diff --git a/target/classes/squier/john/accessControl/TransactionType.class b/target/classes/squier/john/accessControl/TransactionType.class
new file mode 100644
index 0000000..440b8e5
Binary files /dev/null and b/target/classes/squier/john/accessControl/TransactionType.class differ
diff --git a/target/test-classes/squier/john/accessControl/BankAccountTest.class b/target/test-classes/squier/john/accessControl/BankAccountTest.class
new file mode 100644
index 0000000..57ee278
Binary files /dev/null and b/target/test-classes/squier/john/accessControl/BankAccountTest.class differ