diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..54ac10d
Binary files /dev/null and b/.DS_Store differ
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1062418
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.idea/
+*.iml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..74d2d2d
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ 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..233a7f0
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..b1643fd
--- /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..94a25f7
--- /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..e77162c
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,1477 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ io.zihaocastine.*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ DEFINITION_ORDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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+
+
+
+
+
+
+
+
+
+
+
+
+ No facets are configured
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+ BankAccount
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+ Maven: junit:junit:4.12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BankAccount.iml b/BankAccount.iml
new file mode 100644
index 0000000..5cf6df2
--- /dev/null
+++ b/BankAccount.iml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index cac8b1d..2d4fc81 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,5 @@
+# BankAccountLab
+=======
# project-2-ATM
Week 2 project: ATM Simulator
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..37b8e41
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,18 @@
+
+
+ 4.0.0
+
+ castine.zihao
+ bankAccount
+ 1.0-SNAPSHOT
+
+
+ junit
+ junit
+ 4.12
+
+
+
+
\ No newline at end of file
diff --git a/src/.DS_Store b/src/.DS_Store
new file mode 100644
index 0000000..f82fe7d
Binary files /dev/null and b/src/.DS_Store differ
diff --git a/src/main/java/io/zihaocastine/ATMDriver.java b/src/main/java/io/zihaocastine/ATMDriver.java
new file mode 100644
index 0000000..b9620cb
--- /dev/null
+++ b/src/main/java/io/zihaocastine/ATMDriver.java
@@ -0,0 +1,251 @@
+package io.zihaocastine;
+
+import java.util.ArrayList;
+import java.util.Scanner;
+
+/**
+ * Created by zihaocastine on 5/9/16.
+ */
+public class ATMDriver {
+ int userNum;
+ int accountNum;
+
+ public static void main(String[] args) {
+ ATMDriver atmDriver=new ATMDriver();
+ atmDriver.start();
+ }
+ public void start(){
+ //ArrayList accountList=new ArrayList();
+ ArrayList users=new ArrayList();
+ Scanner input=new Scanner(System.in);
+ int choice=-5;
+ userNum =0;
+ accountNum =0;
+ userPrintOption();
+ System.out.print("Enter: ");
+ choice = input.nextByte();
+ while(choice!=0) {
+ switch (choice){
+ case 1:users.add(createUser());
+ break;
+ case 2:choiceUser(users);
+ break;
+ default:
+ break;
+ }
+ while (choice != -1 && !users.isEmpty()) {
+ accountPrintOption();
+ System.out.print("Enter: ");
+ choice = input.nextByte();
+ switch (choice) {
+ case 1:
+ users.get(userNum).getAccountList().add(createAccount());
+ break;
+ case 2:
+ choiceAccount(users.get(userNum));
+ break;
+ case 3:
+ if(hasAccount(users.get(userNum))){
+ System.out.println("Account # " + users.get(userNum).getAccountList().get(accountNum).getAccountNumber() + " balance is " + users.get(userNum).getAccountList().get(accountNum).getBalance());
+ }
+ break;
+ case 4:
+ if(hasAccount(users.get(userNum))){
+ withdrawAccount(users.get(userNum).getAccountList().get(accountNum));
+ }
+ break;
+ case 5:
+ if(hasAccount(users.get(userNum))) {
+ depositAccount(users.get(userNum).getAccountList().get(accountNum));
+ }
+ break;
+ case 6:
+ if(hasAccount(users.get(userNum))) {
+ if (users.get(userNum).getAccountList().size() > 1) {
+ transferAccount(users.get(userNum).getAccountList().get(accountNum));
+ } else {
+ System.out.println("You will need more than one account to transfer");
+ }
+ }
+ break;
+ case 7:
+ if(hasAccount(users.get(userNum))) {
+ if (closeAccount(users.get(userNum).getAccountList().get(accountNum))) {
+ System.out.println("Account # " + users.get(userNum).getAccountList().get(accountNum).getAccountNumber() + " is now closed");
+ } else {
+ System.out.println("Account # " + users.get(userNum).getAccountList().get(accountNum).getAccountNumber() + " is unable to close due to remaining balance " + users.get(userNum).getAccountList().get(accountNum).getBalance());
+ }
+ }
+ break;
+ case 8:
+ if(hasAccount(users.get(userNum))) {
+ printAccountHistory(users.get(userNum).getAccountList().get(accountNum));
+ }
+ default:
+ break;
+
+ }
+ }
+ userNum++;
+ userPrintOption();
+ System.out.print("Enter: ");
+ choice = input.nextByte();
+ }
+
+ }
+ private void userPrintOption(){
+ System.out.println("Enter 0 to exit");
+ System.out.println( "1) New user");
+ System.out.println( "2) Existing user");
+ }
+
+ private void accountPrintOption(){
+ System.out.println("Enter -1 to exit");
+ System.out.println( "1) Open new account");
+ System.out.println( "2) Existing account");
+ System.out.println( "3) Check balance");
+ System.out.println( "4) Withdraw from account");
+ System.out.println( "5) Deposit to account");
+ System.out.println( "6) Transfer across accounts (self)");
+ System.out.println( "7) Close account (must be empty)");
+ System.out.println( "8) Print transaction history");
+
+ }
+
+ private Account createAccount(){
+ Account account;
+ Scanner input=new Scanner(System.in);
+ System.out.println("Enter the type of account (c for checking, s for saving, i for investment");
+ String type=input.next();
+ System.out.println("Enter an account number");
+ int number=input.nextInt();
+ System.out.println("Enter the name of the account");
+ String name=input.nextLine();
+ input.nextLine();
+ System.out.println("Enter the balance of the account");
+ int balance=input.nextInt();
+ switch (type.toLowerCase()){
+ case "c": account =new Account(Account.AccountType.CHECKING, number,name,balance);
+ break;
+ case "s": account =new Account(Account.AccountType.SAVING, number,name,balance);
+ break;
+ case "i": account =new Account(Account.AccountType.INVESTMENT, number,name,balance);
+ break;
+ default: account =new Account(Account.AccountType.CHECKING, number,name,balance);
+ break;
+ }
+
+ return account;
+ }
+
+ private boolean hasAccount(User user){
+ if(user.getAccountList().size()>0){
+ return true;
+ }else{
+ System.out.println("You don't have any account under this user");
+ return false;
+ }
+
+ }
+
+ private User createUser(){
+ User user;
+ Scanner input=new Scanner(System.in);
+ System.out.println("Enter username: ");
+ String username=input.nextLine();
+ System.out.println("Enter password: ");
+ String password=input.next();
+ user=new User(username,password);
+
+ return user;
+ }
+
+ private void withdrawAccount(Account account){
+ double amount=0;
+ Scanner input= new Scanner(System.in);
+ System.out.print("Enter the amount you want to withdrawal: ");
+ amount=input.nextDouble();
+ Transaction transaction=new Transaction(Transaction.TransactionType.WITHDRAWALS,amount,account,null);
+ transaction.makeTransaction();
+ }
+
+ private void depositAccount(Account account){
+ double amount=0;
+ Scanner input= new Scanner(System.in);
+ System.out.print("Enter the amount you want to deposit: ");
+ amount=input.nextDouble();
+ Transaction transaction=new Transaction(Transaction.TransactionType.DEPOSITS,amount,account,null);
+ transaction.makeTransaction();
+ }
+
+ private void transferAccount(Account account){
+ double amount=0;
+ System.out.println("Enter the account you want to transfer");
+ Account accountTo =createTempAccount();
+ Scanner input= new Scanner(System.in);
+ System.out.print("Enter the amount you want to transfer: ");
+ amount=input.nextDouble();
+ Transaction transaction=new Transaction(Transaction.TransactionType.TRANSFERS,amount,account,accountTo);
+ transaction.makeTransaction();
+ }
+
+ private boolean closeAccount(Account account){
+ if(account.getBalance()==0){
+ account.changeStatus(Account.Status.CLOSED);
+ return true;
+ }else {
+ return false;
+ }
+ }
+
+ private void printAccountHistory(Account account){
+ System.out.println(account.getRecord().toString());
+
+ }
+
+ private void choiceUser(ArrayList users){
+ // users.equals(createUser());
+
+ User tempUser=createUser();
+ for (User each: users ) {
+ if( each.getUsername().equals(tempUser.getUsername())&& each.getPassword().equals(tempUser.getPassword())){
+ userNum =users.indexOf(each);
+ }
+ }
+ }
+
+ private void choiceAccount(User user){
+ Account tempAccount=createTempAccount();
+ for (Account each: user.getAccountList() ) {
+ if( each.getAccountType().equals(tempAccount.getAccountType())&& each.getAccountNumber() ==tempAccount.getAccountNumber()){
+ accountNum =user.getAccountList().indexOf(each);
+ }
+ }
+
+ }
+
+ private Account createTempAccount(){
+ Account tempAccount;
+ Scanner input=new Scanner(System.in);
+ System.out.println("Enter the type of account (c for checking, s for saving, i for investment");
+ String type=input.next();
+ System.out.println("Enter an account number");
+ int number=input.nextInt();
+ System.out.println("Enter the name of the account");
+ String name=input.nextLine();
+ input.nextLine();
+ switch (type.toLowerCase()){
+ case "c": tempAccount =new Account(Account.AccountType.CHECKING, number,name);
+ break;
+ case "s": tempAccount =new Account(Account.AccountType.SAVING, number,name);
+ break;
+ case "i": tempAccount =new Account(Account.AccountType.INVESTMENT, number,name);
+ break;
+ default: tempAccount =new Account(Account.AccountType.CHECKING, number,name);
+ break;
+ }
+
+ return tempAccount;
+ }
+
+}
diff --git a/src/main/java/io/zihaocastine/Account.java b/src/main/java/io/zihaocastine/Account.java
new file mode 100644
index 0000000..3aa2006
--- /dev/null
+++ b/src/main/java/io/zihaocastine/Account.java
@@ -0,0 +1,142 @@
+package io.zihaocastine;
+
+import java.util.ArrayList;
+
+/**
+ * Created by zihaocastine on 5/2/16.
+ */
+public class Account {
+ private AccountType accountType;
+ private int accountNumber;
+ private String accountName;
+ private double balance;
+ private double interestRate;
+ private Status status;
+ private boolean overDraft;
+ private ArrayList record;
+
+ public enum AccountType{CHECKING, SAVING, INVESTMENT}
+ public enum Status{OPEN, CLOSED, OFACFREEZE}
+
+ Account(AccountType accountType,int accountNumber, String accountName){
+ this.accountType=accountType;
+ this.accountNumber=accountNumber;
+ this.accountName=accountName;
+ balance=0;
+ interestRate=0;
+ status=Status.OPEN;
+ overDraft=false;
+ record=new ArrayList();
+ }
+
+ Account(AccountType accountType,int accountNumber,String accountName,double balance){
+ this.accountType=accountType;
+ this.accountNumber=accountNumber;
+ this.accountName=accountName;
+ this.balance=balance;
+ interestRate=0;
+ status=Status.OPEN;
+ overDraft=false;
+ record=new ArrayList();
+ }
+
+ Account(AccountType accountType,int accountNumber,String accountName,double balance,double interestRate){
+ this.accountType=accountType;
+ this.accountNumber=accountNumber;
+ this.accountName=accountName;
+ this.balance=balance;
+ this.interestRate=interestRate;
+ status=Status.OPEN;
+ overDraft=false;
+ record=new ArrayList();
+ }
+
+ public double getBalance() {
+ if(!status.equals(Status.OFACFREEZE)){
+ return balance;
+ }
+ return -9999;
+ }
+
+ private void setBalance(double balance) {
+
+ this.balance = balance;
+ }
+
+ public boolean debit(double amount){
+ if(isAccountOpen()){
+ if((balance-amount)>=0) {
+ setBalance(balance - amount);
+ record.add("debit " + amount);
+ return true;
+ }else {
+ return false;
+ }
+ }else {
+ return false;
+ }
+ }
+
+ public boolean credit(double amount){
+ if(isAccountOpen()){
+ setBalance(balance+amount);
+ record.add("credit "+amount);
+ return true;
+ }else {
+ return false;
+ }
+ }
+
+ public boolean isAccountOpen(){
+ if(status.equals(Status.OPEN)){
+ return true;
+ }else {
+ return false;
+ }
+
+ }
+ public AccountType getAccountType() {
+ return accountType;
+ }
+
+ public int getAccountNumber() {
+ return accountNumber;
+ }
+
+
+ public String getAccountName() {
+ return accountName;
+ }
+
+ public void changeAccountName(String accountName) {
+ if(!status.equals(Status.CLOSED)) {
+ this.accountName = accountName;
+ record.add("changeAccountName "+accountName);
+ }
+ }
+
+ public void setInterestRate(double interestRate) {
+ this.interestRate = interestRate;
+ }
+
+ public void changeStatus(Status status) {
+ if(!status.equals(Status.CLOSED)) {
+ this.status = status;
+ record.add("changeStatus"+status);
+ }
+ }
+
+ public void changeOverDraft(boolean overDraft) {
+ this.overDraft = overDraft;
+ record.add("changeOverDraft "+overDraft);
+ }
+
+ public void setRecord(String steatment) {
+ record.add(steatment);
+ }
+
+ public ArrayList getRecord() {
+ return record;
+ }
+
+}
diff --git a/src/main/java/io/zihaocastine/Transaction.java b/src/main/java/io/zihaocastine/Transaction.java
new file mode 100644
index 0000000..f3d80c1
--- /dev/null
+++ b/src/main/java/io/zihaocastine/Transaction.java
@@ -0,0 +1,67 @@
+package io.zihaocastine;
+
+
+import java.util.Date;
+
+/**
+ * Created by zihaocastine on 5/3/16.
+ */
+public class Transaction {
+ private TransactionType transactionType;
+ private double amount;
+ private Account sourceAccount;
+ private Account destinationAccount;
+ private Date timeStamp;
+ private String FTN;
+ public enum TransactionType{
+ WITHDRAWALS, DEPOSITS, TRANSFERS
+ }
+
+ Transaction(TransactionType transactionType, double amount, Account sourceAccount, Account destinationAccount){
+ this.transactionType=transactionType;
+ this.amount=amount;
+ this.sourceAccount=sourceAccount;
+ this.destinationAccount=destinationAccount;
+ //timeStamp=new Date();
+ }
+
+ public void makeTransaction(){
+ switch (transactionType){
+ case WITHDRAWALS:
+ if (sourceAccount.debit(amount)){
+ timeStamp=new Date();
+ sourceAccount.setRecord("Withdrawal " +amount+" time: "+timeStamp);
+ }else {
+ System.out.println("Transaction fail");
+ sourceAccount.setRecord("Withdrawal fail, time: "+timeStamp);
+ }
+ break;
+ case DEPOSITS:
+ sourceAccount.credit(amount);
+ timeStamp=new Date();
+ sourceAccount.setRecord("Deposit " +amount);
+ break;
+ case TRANSFERS:
+ if(destinationAccount.getAccountName()!="null"){
+ if (sourceAccount.debit(amount)){
+ timeStamp=new Date();
+ sourceAccount.setRecord("Withdrawal " +amount+", time: "+timeStamp);
+ destinationAccount.credit(amount);
+ sourceAccount.setRecord("Transfer "+amount+" to "+destinationAccount.getAccountName());
+ destinationAccount.setRecord(amount+" transfer from "+sourceAccount.getAccountName());
+ }else {
+ System.out.println("Transaction fail");
+ sourceAccount.setRecord("Transfer fail, time: "+timeStamp);
+ }
+
+ }
+ break;
+ default:System.out.println("makeTransaction error");
+ }
+ }
+
+
+
+
+
+}
diff --git a/src/main/java/io/zihaocastine/User.java b/src/main/java/io/zihaocastine/User.java
new file mode 100644
index 0000000..324bbdb
--- /dev/null
+++ b/src/main/java/io/zihaocastine/User.java
@@ -0,0 +1,42 @@
+package io.zihaocastine;
+
+import java.util.ArrayList;
+
+/**
+ * Created by zihaocastine on 5/10/16.
+ */
+public class User {
+ private String username;
+ private String password;
+ private ArrayList accountList;
+
+ User(String username, String password){
+ this.username=username;
+ this.password=password;
+ accountList=new ArrayList();
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public ArrayList getAccountList() {
+ return accountList;
+ }
+
+ public void AccountList(ArrayList accountList) {
+ this.accountList = accountList;
+ }
+}
diff --git a/src/test/java/io/zihaocastine/AccountTest.java b/src/test/java/io/zihaocastine/AccountTest.java
new file mode 100644
index 0000000..909faab
--- /dev/null
+++ b/src/test/java/io/zihaocastine/AccountTest.java
@@ -0,0 +1,53 @@
+package io.zihaocastine;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Created by zihaocastine on 5/3/16.
+ */
+public class AccountTest {
+ @Test
+ public void TestAccount() {
+ Account account = new Account(Account.AccountType.CHECKING, 12345, "Zihao");
+ String expectedName = "Zihao";
+ Assert.assertEquals(expectedName, account.getAccountName());
+ Account.AccountType expectedType = Account.AccountType.CHECKING;
+ Assert.assertEquals(expectedType, account.getAccountType());
+ int expectedNumber = 12345;
+ Assert.assertEquals(expectedNumber, account.getAccountNumber());
+
+ }
+ @Test
+ public void TestBalance() {
+ Account account = new Account(Account.AccountType.CHECKING, 12345, "Zihao",500);
+ String expectedName="Zihao";
+ Assert.assertEquals(expectedName,account.getAccountName());
+ Account.AccountType expectedType = Account.AccountType.CHECKING;
+ Assert.assertEquals(expectedType,account.getAccountType());
+ int expectedNumber=12345;
+ Assert.assertEquals(expectedNumber,account.getAccountNumber());
+ double expectedBalance=500;
+ Assert.assertEquals(expectedBalance,500,0);
+ }
+ @Test
+ public void TestDebit() {
+ Account account = new Account(Account.AccountType.CHECKING, 12345, "Zihao",500);
+ double expectedBalance=500;
+ Assert.assertEquals(expectedBalance,500,0);
+ account.debit(50);
+ double expectedAfterChecking=450;
+ Assert.assertEquals(expectedAfterChecking,account.getBalance(),0);
+ }
+ @Test
+ public void TestCredit() {
+ Account account = new Account(Account.AccountType.CHECKING, 12345, "Zihao",500);
+ double expectedBalance=500;
+ Assert.assertEquals(expectedBalance,500,0);
+ account.credit(50);
+ double expectedAfterCredit=550;
+ Assert.assertEquals(expectedAfterCredit,account.getBalance(),0);
+ }
+
+
+}
diff --git a/src/test/java/io/zihaocastine/TransactionTest.java b/src/test/java/io/zihaocastine/TransactionTest.java
new file mode 100644
index 0000000..b75d51c
--- /dev/null
+++ b/src/test/java/io/zihaocastine/TransactionTest.java
@@ -0,0 +1,40 @@
+package io.zihaocastine;
+
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Created by zihaocastine on 5/3/16.
+ */
+public class TransactionTest {
+ @Test
+ public void makeTransactionDepositsTest(){
+ Account account1 = new Account(Account.AccountType.CHECKING, 12345, "Zihao",500);
+ Transaction transaction=new Transaction(Transaction.TransactionType.DEPOSITS,200,account1,null);
+ transaction.makeTransaction();
+
+ Assert.assertEquals("Value should be 700", 700,account1.getBalance(),0);
+
+ }
+ @Test
+ public void makeTransactionWithdrawalTest(){
+ Account account1 = new Account(Account.AccountType.CHECKING, 12345, "Zihao",500);
+ Transaction transaction=new Transaction(Transaction.TransactionType.WITHDRAWALS,200,account1,null);
+ transaction.makeTransaction();
+
+ Assert.assertEquals("Value should be 300", 300,account1.getBalance(),0);
+
+ }
+ @Test
+ public void makeTransactionTransferTest(){
+ Account account1 = new Account(Account.AccountType.CHECKING, 12345, "Zihao",500);
+ Account account2 = new Account(Account.AccountType.CHECKING, 56789, "Castine",1000);
+ Transaction transaction=new Transaction(Transaction.TransactionType.TRANSFERS,200,account1,account2);
+ transaction.makeTransaction();
+ Assert.assertEquals("account1 balance should be 300", 300,account1.getBalance(),0);
+ Assert.assertEquals("account2 balance should be 1200", 1200,account2.getBalance(),0);
+
+ }
+
+}
diff --git a/target/.DS_Store b/target/.DS_Store
new file mode 100644
index 0000000..944f647
Binary files /dev/null and b/target/.DS_Store differ
diff --git a/target/classes/io/zihaocastine/ATMDriver.class b/target/classes/io/zihaocastine/ATMDriver.class
new file mode 100644
index 0000000..74b2923
Binary files /dev/null and b/target/classes/io/zihaocastine/ATMDriver.class differ
diff --git a/target/classes/io/zihaocastine/Account$AccountType.class b/target/classes/io/zihaocastine/Account$AccountType.class
new file mode 100644
index 0000000..df86772
Binary files /dev/null and b/target/classes/io/zihaocastine/Account$AccountType.class differ
diff --git a/target/classes/io/zihaocastine/Account$Status.class b/target/classes/io/zihaocastine/Account$Status.class
new file mode 100644
index 0000000..4e2daab
Binary files /dev/null and b/target/classes/io/zihaocastine/Account$Status.class differ
diff --git a/target/classes/io/zihaocastine/Account.class b/target/classes/io/zihaocastine/Account.class
new file mode 100644
index 0000000..7e475c7
Binary files /dev/null and b/target/classes/io/zihaocastine/Account.class differ
diff --git a/target/classes/io/zihaocastine/Transaction$1.class b/target/classes/io/zihaocastine/Transaction$1.class
new file mode 100644
index 0000000..9502a48
Binary files /dev/null and b/target/classes/io/zihaocastine/Transaction$1.class differ
diff --git a/target/classes/io/zihaocastine/Transaction$TransactionType.class b/target/classes/io/zihaocastine/Transaction$TransactionType.class
new file mode 100644
index 0000000..d2f1e9c
Binary files /dev/null and b/target/classes/io/zihaocastine/Transaction$TransactionType.class differ
diff --git a/target/classes/io/zihaocastine/Transaction.class b/target/classes/io/zihaocastine/Transaction.class
new file mode 100644
index 0000000..895d0b3
Binary files /dev/null and b/target/classes/io/zihaocastine/Transaction.class differ
diff --git a/target/classes/io/zihaocastine/User.class b/target/classes/io/zihaocastine/User.class
new file mode 100644
index 0000000..59edf27
Binary files /dev/null and b/target/classes/io/zihaocastine/User.class differ
diff --git a/target/test-classes/io/zihaocastine/AccountTest.class b/target/test-classes/io/zihaocastine/AccountTest.class
new file mode 100644
index 0000000..79ba282
Binary files /dev/null and b/target/test-classes/io/zihaocastine/AccountTest.class differ
diff --git a/target/test-classes/io/zihaocastine/TransactionTest.class b/target/test-classes/io/zihaocastine/TransactionTest.class
new file mode 100644
index 0000000..c8e64e1
Binary files /dev/null and b/target/test-classes/io/zihaocastine/TransactionTest.class differ