diff --git a/Zipcode ATM Lab UML.xml b/Zipcode ATM Lab UML.xml new file mode 100644 index 0000000..4d9dad8 --- /dev/null +++ b/Zipcode ATM Lab UML.xml @@ -0,0 +1 @@ +7Vzfc5s4EP5rPHP34Azitx+dtLl2pu11Jun07t4UUAxTjDghx8n99SchBEjIju2A7aR9iWElVmK/b1fSSmTiXC0f/yCwSD7jGGUT24ofJ867iW0DYFvsh0uehCQIbCFYkDSuK7WCm/Q/VAvr5xarNEalUpFinNG0UIURznMUUUUGCcFrtdo9ztRWC7hAPcFNBDMpvfBa+fc0pol8M3/WFnxA6SKpGw9tXxTcwejHguBVXreY4xyJkiWUauq3LBMY43VH5LyfOFcEYyqulo9XKOOGlTaTz9En2dGJc5nQZcZuALusiq83PAx2eZi9F0E57Ta3UZ8f2LHvu65zPwPozpvWDTzAbCUbsP2M6boslHb9f1f8DS+XkCzSfOLMWalVPLK/VS8sIZ9SXIgyt1+WoXsqCkH3SYoe6RRm6aLWWlVr2mNXi/q36tWdFPyTFhGjMHtgfvuZ/f0EWZH17fMn9nfKpZDgnP1+QCTlF+JxZpk7XSWTFa1MM3fH1iUl+EdDrEqSwILXWz4uuEtdlE/lMrsoGJkqqnaBwg+I3GcVce5TBolzuU5Sim5YZa5hzZ5nMl50hTNMmKjioHPJNMcpQ1cT3+Oc1i4IOCdqA76LWFXE6l1m8A5lfzGJYwcXvmvkigQfEQZCR1Rz5w+El4iSJ1alLnVAIB6pQ4Q9q11u3XU3Sfmk42ozu64Jay9fNMpburKLmrG7stfak7462WpzqUztMthq/z5LyXkUsRBCd+eakCVkp65u94vdXnejDrjk9MvvSv4zrSJiBvMIVZbhT8Z4dceUb3mNl/SAtwiF9b6slk2jqWLMsVq8fSra97yhJM0XY7ZKCcxLGFEWlT6kJcWVf4mH5oTAp09MyCUSlKrRpltC9iynXkgHwWuyC3t/tXSqlqZV3KVJTOCaXf72e8OjB8wipubUXUrtKerdj/Y6sVRUFjCXBajAZUp3ecOmY93Hxwa621bj3/eI3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vgiTz3Sm3zrWYgzeBtrFMarDWMQ8LvT7XCwJ1I9W0h9fk2LuuB8AAH6j4+35ONarrbd08P2PveysbR75h23K8jSN/83GKUyzVtu5V/yLf6OQz7ZkbyWfPhiCfKdGqWQnl8Zx/5svuqhNqaaTaii8k+AeLVn39N7++8PhdzrrDi8CFBeS9KLZsef8VkZT1m59YeGc1RkVx76Ph3rG1Eq9IhNTJExu4F0jOygKz6TuW9UyTuVpGUAZp+qB2w2TsuoWvuNpJaEY07aicG2h4ie7XT7WQ9RXNNEX6uRXxzj1FFfbNa+9GB1Pa6FA6XNhh0KGE5AC71SFveGJdAGCrRPF9b2CmBH2mmD+vPhVzeocsdU/flTmua6uKpLuPwJzZAMxpaeApJNgLayUCeKfE0Q99xfzhoRFAVxToiobDUWoeJgKEgd+JAFMW9kXc3xYDeC09CHh2OHAQ8HYJAtY5jR/+oVFAHz98PVkxIHtM66gD2QMkDZopheOGzw8gluWr3HE8f1junBlPANCjvJwL7UuU/kJo5o7GFNOq5+A4M2Md7TDlWZZoDKm+jBmfIWq4Eeu+07HGAQrWLrAPZA0IZ4omx9X4NyBrTJ+AvCC+hEp88d3ZnswBAw9LOxFHHHQ+2bAkY8KTdr8vb0L5HYlUpB8CH5A2prO5m2nT/4puy0IW+C8eXk62ztDOeAFLX1keOsXoaxoQzP1SFj8LmPreFbD05OSuYOrLz76mAcHcL+HQB/O1weIeOjkL9G9ndUUDgmLaiHxLoOhflPvg0Bkz8DVNI8a9/TIsrw+Vfio8PDCCAdext2s6GBZ22/7PSFG9/a+czvv/AQ== \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9901415..103f50a 100644 --- a/pom.xml +++ b/pom.xml @@ -8,5 +8,15 @@ project-2-atm 1.0-SNAPSHOT + + + + junit + junit + 4.12 + + + + \ No newline at end of file diff --git a/src/main/java/Account.java b/src/main/java/Account.java new file mode 100644 index 0000000..5bf36e9 --- /dev/null +++ b/src/main/java/Account.java @@ -0,0 +1,75 @@ +import java.util.ArrayList; + +public class Account { + + private double balance; + private int accountNum; + private String accountType; + private ArrayList transactionHistory = new ArrayList(); + + + public Account(double balance, int accountNum, String accountType) { + this.balance = balance; + this.accountNum = accountNum; + this.accountType = accountType; + + } + + public double withdraw(double userAmount) { + + this.balance -= userAmount; + return balance; + } + + public double deposit(double userAmount) { + + this.balance += userAmount; + return balance; + } + + private void transferTo() { + + + } + + private void viewTransactions() { + + } + + public double showBalance(double balanceAmount) { + + this.balance = balanceAmount; + return balanceAmount; + } + + double getBalance() { + + return balance; + } + + public void setBalance(double newBalance) { + + + } + + int getAccountNum() { + + return accountNum; + } + + public void setAccountNum(double newAccountNum) { + + } + + String getAccountType() { + + return accountType; + } + + public ArrayList getTransactionHistory() { + + return transactionHistory; + } + + +} diff --git a/src/main/java/Account_Test.java b/src/main/java/Account_Test.java new file mode 100644 index 0000000..008127f --- /dev/null +++ b/src/main/java/Account_Test.java @@ -0,0 +1,83 @@ +import org.junit.Assert; +import org.junit.Test; + +public class Account_Test { + + @Test + public void AccountTest() { + //: Given + Account getBalNumTypeTest = new Account(123, 123, "Checking"); + double expected = 123; + int expected2 = 123; + String expected3 = "Checking"; + + //: When + double actual = getBalNumTypeTest.getBalance(); + int actual2 = getBalNumTypeTest.getAccountNum(); + String actual3 = getBalNumTypeTest.getAccountType(); + + //: Then + Assert.assertTrue(expected == actual); + Assert.assertEquals(expected2, actual2); + Assert.assertEquals(expected3, actual3); + + } + + @Test + public void withdrawTest() { + //: Given + Account withdrawTest = new Account(123, 456, "Savings"); + double expected = 100; + int expected2 = 456; + String expected3 = "Savings"; + //: When + double actual = withdrawTest.withdraw(23); + int actual2 = 456; + String actual3 = "Savings"; + //: Then + Assert.assertTrue(expected == actual); + Assert.assertEquals(expected2, actual2); + Assert.assertEquals(expected3, actual3); + + + } + + @Test + public void depositTest() { + //: Given + Account depositTest = new Account(123, 789, "Investment"); + double expected = 150; + int expected2 = 789; + String expected3 = "Investment"; + //: When + double actual = depositTest.deposit(27); + int actual2 = 789; + String actual3 = "Investment"; + //: Then + Assert.assertTrue(expected == actual); + Assert.assertEquals(expected2, actual2); + Assert.assertEquals(expected3, actual3); + } + + @Test + public void showBalanceTest() { + //: Given + Account showBalanceTest = new Account(123,101112,"Checking"); + double expected = 200; + double expected2 = 200; + int expected3 = 101112; + String expected4 = "Checking"; + //: When + double actual = showBalanceTest.deposit(77); + double actual2 = showBalanceTest.showBalance(200); + int actual3 = 101112; + String actual4 = "Checking"; + //: Then + Assert.assertTrue(expected == actual); + Assert.assertTrue (expected2 == actual2); + Assert.assertEquals(expected3, actual3); + Assert.assertEquals(expected4, actual4); + } + + +} \ No newline at end of file diff --git a/src/main/java/Checking.java b/src/main/java/Checking.java new file mode 100644 index 0000000..df69c49 --- /dev/null +++ b/src/main/java/Checking.java @@ -0,0 +1,5 @@ +public class Checking extends Account { + public Checking(double balance, int accountNum, String accountType) { + super(balance, accountNum, accountType); + } +} diff --git a/src/main/java/Console.java b/src/main/java/Console.java new file mode 100644 index 0000000..397658b --- /dev/null +++ b/src/main/java/Console.java @@ -0,0 +1,148 @@ +//package com.company; +// +//import java.util.Scanner; +// +//public class Console { +// +// public static void main(String[] args) { +// +// Scanner userInput = new Scanner(System.in); +// +// +// //User log-in interface: +// System.out.println("Existing user? Select '1' to log-in;\n" + +// " New user? Select '2' to create a new account"); +// +// int loginReply = userInput.nextInt(); +// if (loginReply == 1) { +// System.out.println("Please enter your username"); +// } else { +// /*need to setup Account Factory*/ +// } +// +// String username = userInput.nextLine(); +// if (username.equalsIgnoreCase(/*need to setup username system*/)) { +// System.out.println("Please enter your password"); +// } else { +// System.out.println("Incorrect username, please try again"); +// } +// +// String password = userInput.nextLine(); +// if (password.equalsIgnoreCase(/*need to setup password system*/)) { +// //if password accepted need to take user to user account selection stage +// } else { +// System.out.println("Incorrect password, please try again"); +// } +// +// +// //User account interactions/transactions: +// while ( boolean exit !=false){ +// System.out.println("Choose an account:\n " + +// "Select '1' for Checking\n " + +// "Select '2' for Savings\n " + +// "Select '3' for Investment\n" + +// "Select '4' to log-out and exit this session"); +// int chooseAccountReply = userInput.nextInt(); +// if (chooseAccountReply == 1) { +// //call checking +// int chooseTransactionReply = userInput.nextInt(); +// System.out.println("Choose a transaction type or option: " + +// "Select '1' to withdraw from your account\n " + +// "Select '2' to deposit into your account\n" + +// "Select '3' to transfer funds to another account\n" + +// "Select '4' to view your transaction history\n" + +// "Select '5' to show your account balance\n" + +// "Select '6' to log-out and exit this session"); +// if (chooseTransactionReply == 1) { +// //call to withdraw from checking +// } +// if (chooseTransactionReply == 2) { +// //call to deposit to checking +// } +// if (chooseTransactionReply == 3) { +// //call to transfer from checking to subsequent chosen account +// } +// if (chooseTransactionReply == 4) { +// //call to view transaction history +// } +// if (chooseTransactionReply == 5) { +// //call to show checking account balance +// } +// if (chooseTransactionReply == 6) { +// exit = false; +// //log-out user and clear console +// } +// } +// if (chooseAccountReply == 2) { +// //call savings +// int chooseTransactionReply2 = userInput.nextInt(); +// System.out.println("Choose a transaction type or option: " + +// "Select '1' to withdraw from your account\n " + +// "Select '2' to deposit into your account\n" + +// "Select '3' to transfer funds to another account\n" + +// "Select '4' to view your transaction history\n" + +// "Select '5' to show your account balance\n" + +// "Select '6' to log-out and exit this session"); +// if (chooseTransactionReply2 == 1) { +// //call to withdraw from savings +// } +// if (chooseTransactionReply2 == 2) { +// //call to deposit to savings +// } +// if (chooseTransactionReply2 == 3) { +// //call to transfer from savings to subsequent chosen account +// } +// if (chooseTransactionReply2 == 4) { +// //call to view transaction history +// } +// if (chooseTransactionReply2 == 5) { +// //call to show savings balance +// } +// if (chooseTransactionReply2 == 6) { +// exit = false; +// //log-out user and clear console +// } +// +// } +// if (chooseAccountReply == 3) { +// //call investment +// int chooseTransactionReply3 = userInput.nextInt(); +// System.out.println("Choose a transaction type or option: " + +// "Select '1' to withdraw from your account\n " + +// "Select '2' to deposit into your account\n" + +// "Select '3' to transfer funds to another account\n" + +// "Select '4' to view your transaction history\n" + +// "Select '5' to show your account balance\n" + +// "Select '6' to log-out and exit this session"); +// if (chooseTransactionReply3 == 1) { +// //call to withdraw from investment +// } +// if (chooseTransactionReply3 == 2) { +// //call to deposit to investment +// } +// if (chooseTransactionReply3 == 3) { +// //call to transfer from investment to subsequent chosen account +// } +// if (chooseTransactionReply3 == 4) { +// //call to view transaction history +// } +// if (chooseTransactionReply3 == 5) { +// //call to show investment account balance +// } +// if (chooseTransactionReply3 == 6) { +// exit = false; +// //log-out user and clear console +// } +// } +// if (chooseAccountReply == 4) { +// exit = false; +// //log-out user and clear console +// +// } +// +// +// } +// +// } +// +//} diff --git a/src/main/java/Investment.java b/src/main/java/Investment.java new file mode 100644 index 0000000..f29755a --- /dev/null +++ b/src/main/java/Investment.java @@ -0,0 +1,5 @@ +public class Investment extends Account { + public Investment(double balance, int accountNum, String accountType) { + super(balance, accountNum, accountType); + } +} diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 05e41a9..a9fee92 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -1,9 +1,7 @@ -/** - * Created by iyasuwatts on 10/17/17. - */ +package com.company; + public class Main { - public static void main(String[] args){ - - } + + } diff --git a/src/main/java/Savings.java b/src/main/java/Savings.java new file mode 100644 index 0000000..e64b86a --- /dev/null +++ b/src/main/java/Savings.java @@ -0,0 +1,5 @@ +public class Savings extends Account { + public Savings(double balance, int accountNum, String accountType) { + super(balance, accountNum, accountType); + } +} diff --git a/src/main/java/User.java b/src/main/java/User.java new file mode 100644 index 0000000..744c9e8 --- /dev/null +++ b/src/main/java/User.java @@ -0,0 +1,45 @@ +import java.util.ArrayList; + +public class User { + + private String userName; + private String password; + private ArrayList userAccounts = new ArrayList(); + + public User (String userName, String password) { + + this.userName = userName; + this.password = password; + + } + + public String createAccount () { + + } + + private void closeAccount () { + + } + + private void logIn () { + + + } + + public String getUserName () { + + return userName; + } + + public String checkPassword () { + + return password; + } + + public ArrayList getAccountFromAL () { + + return userAccounts; + } + + +} diff --git a/src/main/java/User_Factory.java b/src/main/java/User_Factory.java new file mode 100644 index 0000000..185662c --- /dev/null +++ b/src/main/java/User_Factory.java @@ -0,0 +1,13 @@ +public class User_Factory { + + public void createNewUserName () { + + } + + public void createNewPassword () { + + } + + + +} diff --git a/src/main/java/User_Test.java b/src/main/java/User_Test.java new file mode 100644 index 0000000..4ca7ca9 --- /dev/null +++ b/src/main/java/User_Test.java @@ -0,0 +1,25 @@ +import org.junit.Assert; +import org.junit.Test; + +public class User_Test { + + @Test + public void User_Test () { + //: Given + User getUserNameCheckPwordTest = new User ("abc", "123"); + String expected = "abc"; + String expected2 = "123"; + //: When + String actual = getUserNameCheckPwordTest.getUserName(); + String actual2 = getUserNameCheckPwordTest.checkPassword(); + //: Then + Assert.assertEquals(expected, actual); + Assert.assertEquals(expected2, actual2); + + + + + + } + +}