diff --git a/pom.xml b/pom.xml
index 9901415..19115ef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,6 +7,13 @@
io.zipcoder
project-2-atm
1.0-SNAPSHOT
+
+
+ junit
+ junit
+ 4.11
+
+
\ 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..a9a521a
--- /dev/null
+++ b/src/main/java/Account.java
@@ -0,0 +1,31 @@
+public abstract class Account {
+ private final Integer accountNumber;
+ private double balance;
+
+ protected Account(Integer accountNumber, double balance) {
+ this.accountNumber = accountNumber;
+ this.balance = balance;
+ }
+
+ public int getAccountNumber() {
+ return accountNumber;
+ }
+
+ public double getBalance() {
+ return balance;
+ }
+
+ public double withdraw(double amount) {
+ if (balance >= amount && amount >= 0) {
+ balance -= amount;
+ }
+ return balance;
+ }
+
+ public double deposit(double amount) {
+ if (amount > 0) {
+ return balance += amount;
+ } else return balance;
+ }
+
+}
diff --git a/src/main/java/Checking.java b/src/main/java/Checking.java
new file mode 100644
index 0000000..53bdee3
--- /dev/null
+++ b/src/main/java/Checking.java
@@ -0,0 +1,20 @@
+public class Checking extends Account{
+
+ public Checking(Integer accountNumber, double balance) {
+ super(accountNumber,balance);
+ }
+
+ public void transferToSavings(Savings savingsAccount, double transferAmount) {
+ if (this.getBalance() >= transferAmount) {
+ this.withdraw(transferAmount);
+ savingsAccount.deposit(transferAmount);
+ }
+ }
+
+ public void transferToInvestment(Investment investmentAccount, double transferAmount) {
+ if (this.getBalance() >= transferAmount) {
+ this.withdraw(transferAmount);
+ investmentAccount.deposit(transferAmount);
+ }
+ }
+}
diff --git a/src/main/java/Console.java b/src/main/java/Console.java
new file mode 100644
index 0000000..7254d2b
--- /dev/null
+++ b/src/main/java/Console.java
@@ -0,0 +1,51 @@
+import java.util.Scanner;
+
+public class Console {
+
+ public static void print(String output, Object... args) {
+ System.out.printf(output, args);
+ }
+
+ public static void println(String output, Object... args) {
+ print(output + "\n", args);
+ }
+
+ public String getStringInput(String prompt) {
+ Scanner scanner = new Scanner(System.in);
+ println(prompt);
+ String userInput = scanner.nextLine();
+ return userInput;
+ }
+
+ public String getStringInputNotCaseSensitive(String prompt) {
+ Scanner scanner = new Scanner(System.in);
+ println(prompt);
+ String userInput = scanner.nextLine();
+ return userInput.toLowerCase();
+ }
+
+ public Integer getIntegerInput(String prompt) {
+ Scanner scanner = new Scanner(System.in);
+ println(prompt);
+ while (!scanner.hasNextInt()) {
+ System.out.println("Input is not a number.");
+ scanner.nextLine();
+ }
+ int userInput = scanner.nextInt();
+ return userInput;
+
+ }
+
+ public Double getDoubleInput(String prompt) {
+ Scanner scanner = new Scanner(System.in);
+ println(prompt);
+ while (!scanner.hasNextDouble()) {
+ System.out.println("Input is not a number.");
+ scanner.nextLine();
+ }
+ Double userInput = scanner.nextDouble();
+ return userInput;
+
+ }
+
+}
diff --git a/src/main/java/Creator.java b/src/main/java/Creator.java
new file mode 100644
index 0000000..737bb35
--- /dev/null
+++ b/src/main/java/Creator.java
@@ -0,0 +1,22 @@
+public class Creator {
+
+ public static Customer createCustomer(String name, String userName, String password, Account... accounts) {
+ return new Customer(name, userName, password, accounts);
+ }
+
+ public static Checking createChecking(double initialDeposit) {
+ Integer newAccountNumber = (int)(Math.random() * ((999-100) + 1) + 100);
+ return new Checking(newAccountNumber, initialDeposit);
+ }
+
+ public static Savings createSavings(double initialDeposit) {
+ Integer newAccountNumber = (int)(Math.random() * ((9999-1000) + 1) + 1000);
+ return new Savings(newAccountNumber, initialDeposit);
+ }
+
+ public static Investment createInvestment(double initialDeposit) {
+ Integer newAccountNumber = (int)(Math.random() * ((99999-10000) + 1) + 10000);
+ return new Investment(newAccountNumber, initialDeposit);
+ }
+
+}
diff --git a/src/main/java/Customer.java b/src/main/java/Customer.java
new file mode 100644
index 0000000..02bbf6b
--- /dev/null
+++ b/src/main/java/Customer.java
@@ -0,0 +1,75 @@
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class Customer {
+ private String customerName;
+ private String userName;
+ private String password;
+ private ArrayList accounts = new ArrayList();
+
+
+ public Customer(String customerName, String userName, String password, Account... accounts) {
+ this.customerName = customerName;
+ this.userName = userName;
+ this.password = password;
+ if (accounts != null) {
+ this.accounts.addAll(Arrays.asList(accounts));
+ }
+ }
+
+ public String getCustomerName(){ return this.customerName;}
+
+ public void setCustomerName(String customerName){ this.customerName = customerName;}
+
+ public String getUserName(){
+ return this.userName;
+ }
+
+ public void setUserName(String userName){
+ this.userName = userName;
+ }
+
+ public String getPassword(){
+ return this.password;
+ }
+
+ public void setPassword(String password){
+ this.password = password;
+ }
+
+ public String getAccountNumber() {
+ String accountNumbers = "Accounts: \n";
+ for(int i = 0; i < accounts.size(); i++) {
+ accountNumbers += String.format("%d : %s\n", i+1, accounts.get(i).getAccountNumber());
+ }
+ return accountNumbers;
+ }
+
+ public Account getAccount(int accountNumber) {
+ for (Account account : accounts) {
+ if (account.getAccountNumber() == accountNumber) {
+ return account;
+ }
+ }
+ return null;
+ }
+
+ public void addAccount(Account account) {
+ accounts.add(account);
+ }
+
+ public int getNumberOfAccounts() {
+ return accounts.size();
+ }
+
+ public void closeAccount(Integer accountNumber) {
+ for (int i = 0; i < accounts.size(); i++) {
+ if (accounts.get(i).getAccountNumber() == accountNumber) {
+ if (accounts.get(i).getBalance() == 0) {
+ accounts.remove(i);
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/Database.java b/src/main/java/Database.java
new file mode 100644
index 0000000..63cadb7
--- /dev/null
+++ b/src/main/java/Database.java
@@ -0,0 +1,46 @@
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class Database {
+ private static volatile ArrayList currentCustomers = new ArrayList();
+
+ public static void addCustomer(Customer customer) {
+ currentCustomers.add(customer);
+ }
+
+ public static void addMultipleCustomers(Customer... customer) {
+ currentCustomers.addAll(Arrays.asList(customer));
+ }
+
+ public static Customer getCustomerByName(String name) {
+ for(Customer customer : currentCustomers) {
+ if(customer.getCustomerName().equals(name)) {
+ return customer;
+ }
+ }
+ return null;
+ }
+
+ public static Customer getCustomerByUsername(String username) {
+ for(Customer customer : currentCustomers) {
+ if(customer.getUserName().equals(username)) {
+ return customer;
+ }
+ }
+ return null;
+ }
+
+ public static void removeCustomer(Customer customer) {
+ currentCustomers.remove(customer);
+ }
+
+ public static Integer getNumberOfCustomers() {
+ return currentCustomers.size();
+ }
+
+ public static void removeAllCustomers() {
+ currentCustomers.clear();
+ }
+
+
+}
diff --git a/src/main/java/Display.java b/src/main/java/Display.java
new file mode 100644
index 0000000..0e6126e
--- /dev/null
+++ b/src/main/java/Display.java
@@ -0,0 +1,51 @@
+public class Display {
+
+ String currentDisplay;
+ String transactionHistory;
+
+ public Display(){
+ this.currentDisplay = "";
+ this.transactionHistory = "";
+ }
+
+ /* *****Getters and setters***** */
+
+ public void printCurrentDisplay() {
+ System.out.println(currentDisplay);
+ }
+
+ public void setCurrentDisplay(String currentDisplay) {
+ this.currentDisplay = currentDisplay;
+ }
+
+ //set AND print in one
+ public void currentDisplaySP(String currentDisplay){
+ this.setCurrentDisplay(currentDisplay);
+ this.printCurrentDisplay();
+ }
+
+
+
+ public void printTransactionHistory() {
+ System.out.println(transactionHistory);
+ }
+
+ public void setTransactionHistory(String transactionHistory) {
+ this.transactionHistory = transactionHistory;
+ }
+
+ public void addToTransactionHistory(String snippet){
+ this.transactionHistory = this.transactionHistory + snippet;
+ }
+
+
+}
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/Investment.java b/src/main/java/Investment.java
new file mode 100644
index 0000000..d9c72fe
--- /dev/null
+++ b/src/main/java/Investment.java
@@ -0,0 +1,20 @@
+public class Investment extends Account {
+
+ public Investment(Integer accountNumber, double balance) {
+ super(accountNumber, balance);
+ }
+
+ public void transferToSavings(Savings savingsAccount, double transferAmount) {
+ if (this.getBalance() >= transferAmount) {
+ this.withdraw(transferAmount);
+ savingsAccount.deposit(transferAmount);
+ }
+ }
+
+ public void transferToChecking(Checking checkingAccount, double transferAmount) {
+ if (this.getBalance() >= transferAmount) {
+ this.withdraw(transferAmount);
+ checkingAccount.deposit(transferAmount);
+ }
+ }
+}
diff --git a/src/main/java/Main.java b/src/main/java/Main.java
index 05e41a9..3e527de 100644
--- a/src/main/java/Main.java
+++ b/src/main/java/Main.java
@@ -2,8 +2,20 @@
* Created by iyasuwatts on 10/17/17.
*/
public class Main {
+ private boolean engineOn = true;
- public static void main(String[] args){
-
+ public static void main(String[] args) {
+ Main main = new Main();
+ Motherboard ATM = new Motherboard();
+ Workflow screen = new Workflow();
+ Customer xiong = Creator.createCustomer("xiong", "xyuan", "zipcode", new Checking(100, 1500), new Savings(1000, 2500), new Investment(10000, 6000));
+ Customer mike = Creator.createCustomer("mike", "ninh", "zipcode", new Checking(101, 1500), new Savings(1001, 2500), new Investment(10001, 6000));
+ Customer hazel = Creator.createCustomer("hazel", "hbecker", "zipcode", new Checking(102, 1500), new Savings(1002, 2500), new Investment(10002, 6000));
+ Customer lena = Creator.createCustomer("lena", "llitouka", "zipcode", new Checking(103, 1500), new Savings(1003, 2500), new Investment(10003, 6000));
+ Database.addMultipleCustomers(xiong, mike, hazel, lena);
+
+ while (main.engineOn) {
+ ATM.runEngine(screen);
+ }
}
}
diff --git a/src/main/java/Motherboard.java b/src/main/java/Motherboard.java
new file mode 100644
index 0000000..a2599aa
--- /dev/null
+++ b/src/main/java/Motherboard.java
@@ -0,0 +1,319 @@
+import java.util.ArrayList;
+
+public class Motherboard {
+
+ public void runEngine(Workflow screen) {
+ customerLogin(screen);
+ }
+
+ public void customerLogin(Workflow screen) {
+ screen.initialWelcomeSP();
+ boolean test = true;
+ Integer input = screen.getInput();
+ while (test)
+ switch (input) {
+ case 1:
+ createCustomer();
+ test = false;
+ break;
+ case 2:
+ Customer currentUser = validateCredentials(screen);
+ if (currentUser == null) {
+ System.out.println("Sorry cannot log you in at this time");
+ test = false;
+ break;
+ }else if(currentUser.equals("0")){customerLogin(screen);}
+ returningCustomer(screen, currentUser);
+ test = false;
+ break;
+ default:
+ input = screen.getInput();
+ System.out.println("Please choose 1 for new customer or 2 for returning customer.");
+ break;
+ }
+ }
+
+ public Customer validateCredentials(Workflow screen) {
+ screen.returningUserSP();
+ String newUsername = screen.getUserSP();
+ int counter = 0;
+ int tries = 3;
+
+ if(newUsername.equals("0")){customerLogin(screen);}
+
+ while(Database.getCustomerByUsername(newUsername) == null) {
+ System.out.println("Account not on file");
+ newUsername = screen.getUserSP();
+ }
+
+ Customer currentUser = Database.getCustomerByUsername(newUsername);
+
+ while(counter < 3) {
+ String userPass = screen.getPassSP();
+ if(userPass.equals("0")){customerLogin(screen);}
+ if (currentUser.getPassword().equals(userPass)) {
+ return currentUser;
+ } else
+
+ counter++;
+ tries--;
+ System.out.println(String.format("Invalid password: Tries left - %s", tries));
+ }
+ return null;
+ }
+
+ public void createCustomer() {
+ Workflow screen = new Workflow();
+ Customer newCustomer = Creator.createCustomer(null, null, null, null);
+
+ screen.newCustomerNameSP();
+ String newCustomerName = screen.getCustomerNameSP();
+ newCustomer.setCustomerName(newCustomerName);
+ if(newCustomerName.equals("0")){customerLogin(screen);}
+
+ screen.newUserSP();
+ String newUsername = screen.getUserSP();
+ if(newUsername.equals("0")){customerLogin(screen);}
+ boolean user = true;
+
+ while (user)
+ if (Database.getCustomerByUsername(newUsername) != null) {
+ screen.usernameTakenSP();
+ newUsername = screen.getUserSP();
+ } else {
+ newCustomer.setUserName(newUsername);
+ user = false;
+ }
+
+ boolean pass = true;
+ while (pass) {
+ String newPassword = screen.getPassSP();
+ String newPasswordConfirm = screen.getPassSP();
+ if(newPassword.equals("0") || newPasswordConfirm.equals("0")){customerLogin(screen);}
+ if (newPasswordConfirm.equals(newPassword)) {
+ newCustomer.setPassword(newPassword);
+ pass = false;
+ }else {
+ screen.passwordMismatchSP();
+ }
+ }
+
+ System.out.println("Which type of account would you like to open:\nChecking\nSavings\nInvestment");
+ openingAccount(screen, newCustomer);
+ Database.addCustomer(newCustomer);
+ }
+
+ public void returningCustomer(Workflow screen, Customer customer){
+ boolean currentlyUsing = true;
+
+ while(currentlyUsing) {
+ screen.mainMenuSP(customer);
+ Integer input = screen.getInput();
+ switch (input) {
+ case 0:
+ checkAccountNumbers(customer);
+ break;
+ case 1:
+ check(screen, customer);
+ break;
+ case 2:
+ transfer(screen, customer);
+ break;
+ case 3:
+ withdrawal(screen, customer);
+ break;
+ case 4:
+ deposit(screen, customer);
+ break;
+ case 5:
+ openingAccount(screen, customer);
+ break;
+ case 6:
+ closingAccount(screen, customer);
+ break;
+ case 7:
+ history(screen);
+ break;
+ case 8:
+ wireTransfer(screen, customer);
+ break;
+ case 9:
+ screen.logOutSP();
+ currentlyUsing = false;
+ break;
+ }
+ }
+ }
+
+ public void withdrawal(Workflow screen, Customer customer) {
+ boolean validAmount = true;
+ screen.withdrawPromptSP();
+
+ Integer withdrawAccount = screen.enterAccount();
+ while(customer.getAccount(withdrawAccount) == null) {
+ System.out.println("Account not on file");
+ withdrawAccount = screen.enterAccount();
+ }
+
+ while (validAmount) {
+ double withdrawalAmount = screen.amountPromptSP();
+ if (customer.getAccount(withdrawAccount).getBalance() > withdrawalAmount) {
+ customer.getAccount(withdrawAccount).withdraw(withdrawalAmount);
+ validAmount = false;
+ } else System.out.println("Non sufficient funds");
+ }
+
+ screen.completeResultSP(customer.getAccount(withdrawAccount));
+ }
+
+ public void deposit(Workflow screen, Customer customer) {
+ screen.depositPromptSP();
+
+ Integer depositAccount = screen.enterAccount();
+ while(customer.getAccount(depositAccount) == null) {
+ System.out.println("Account not on file");
+ depositAccount = screen.enterAccount();
+ }
+
+ double depositAmount = screen.amountPromptSP();
+
+ customer.getAccount(depositAccount).deposit(depositAmount);
+ screen.completeResultSP(customer.getAccount(depositAccount));
+ }
+
+ public void transfer(Workflow screen, Customer customer) {
+ boolean validAmount = true;
+ screen.transferPromptSP();
+
+ Integer withdrawAccount = screen.enterAccount();
+ while(customer.getAccount(withdrawAccount) == null) {
+ System.out.println("Account not on file");
+ withdrawAccount = screen.enterAccount();
+ }
+
+ Integer depositAccount = screen.enterAccount();
+ while(customer.getAccount(depositAccount) == null) {
+ System.out.println("Account not on file");
+ depositAccount = screen.enterAccount();
+ }
+
+ while (validAmount) {
+ double transferAmount = screen.amountPromptSP();
+ if (customer.getAccount(withdrawAccount).getBalance() >= transferAmount) {
+ customer.getAccount(withdrawAccount).withdraw(transferAmount);
+ customer.getAccount(depositAccount).deposit(transferAmount);
+ validAmount = false;
+ } else System.out.println("Non sufficient funds");
+ }
+ screen.completeResultSP(customer.getAccount(withdrawAccount), customer.getAccount(depositAccount));
+ }
+ public void closingAccount(Workflow screen, Customer customer) {
+ screen.closePrompt();
+ Integer oldAccount=screen.enterAccount();
+ Boolean validAccount=true;
+ while(customer.getAccount(oldAccount)==null){
+ System.out.println("Account not on file");
+ oldAccount=screen.enterAccount();
+ }
+ while(validAccount){
+ if(customer.getAccount(oldAccount).getBalance()==0) {
+ customer.closeAccount(oldAccount);
+ break;
+ }
+ else {
+ System.out.println("Account balance must be ZERO.\n" +
+ "Remaining balance: $" +customer.getAccount(oldAccount).getBalance());
+ break;
+ }
+ }
+ screen.completeResultsNoHistorySP();
+ }
+
+ public void openingAccount(Workflow screen,Customer customer) {
+ String uniqAccount = screen.openPrompt();
+ boolean validType = true;
+ while (validType) {
+ if ("checking".equals(uniqAccount)) {
+ double firstCheckingDeposit = screen.amountPromptSP();
+ Checking uniqChecking = Creator.createChecking(firstCheckingDeposit);
+ customer.addAccount(uniqChecking);
+ System.out.println("User accounts: "+"\n"+customer.getAccountNumber());
+ break;
+ } else if ("savings".equals(uniqAccount)) {
+ double firstSavingDeposit = screen.amountPromptSP();
+ Checking uniqSaving = Creator.createChecking(firstSavingDeposit);
+ customer.addAccount(uniqSaving);
+ System.out.println("User accounts: "+"\n"+customer.getAccountNumber());
+ break;
+ } else if ("investment".equals(uniqAccount)) {
+ double firstInvestmentDeposit = screen.amountPromptSP();
+ Checking uniqInvestment = Creator.createChecking(firstInvestmentDeposit);
+ customer.addAccount(uniqInvestment);
+ System.out.println("User accounts: "+"\n"+customer.getAccountNumber());
+ break;
+ } else {
+ System.out.println("Not a valid entry. Please type in checking, savings, investment");
+ uniqAccount = screen.openPrompt();
+ }
+ }
+ }
+
+ public void checkAccountNumbers(Customer customer) {
+ System.out.println(customer.getAccountNumber());
+ }
+
+ public void check(Workflow screen, Customer customer){
+ screen.checkPromptSP();
+ while(true) {
+ try {
+ Integer acctNumber = screen.enterAccount();
+ screen.checkResultSP(customer.getAccount(acctNumber));
+ break;
+ } catch (Exception e) {
+ screen.errorSP();
+ }
+ }
+ }
+
+ public void history(Workflow screen){
+ screen.printHistory();
+ }
+
+ public void wireTransfer(Workflow screen, Customer customer) {
+
+ Integer withdrawAccount = screen.enterAccount();
+ while(customer.getAccount(withdrawAccount) == null) {
+ System.out.println("Account not on file");
+ withdrawAccount = screen.enterAccount();
+ }
+
+ System.out.println("please enter the username you want to transfer to");
+ String toTransfer = screen.getUserSP2();
+
+ while(Database.getCustomerByUsername(toTransfer) == null) {
+ System.out.println("Account not on file");
+ toTransfer= screen.getUserSP2();
+ }
+
+ Customer transferUser = Database.getCustomerByUsername(toTransfer);
+
+ boolean validAmount = true;
+ screen.transfer2UserPromptSP();
+
+ Integer depositAccount = screen.enterAccount();
+ while(transferUser.getAccount(depositAccount) == null) {
+ System.out.println("Account not on file");
+ depositAccount = screen.enterAccount();
+ }
+
+ while (validAmount) {
+ double transferAmount = screen.amountPromptSP();
+ if (customer.getAccount(withdrawAccount).getBalance() >= transferAmount) {
+ customer.getAccount(withdrawAccount).withdraw(transferAmount);
+ transferUser.getAccount(depositAccount).deposit(transferAmount);
+ validAmount = false;
+ } else System.out.println("Non sufficient funds");
+ }
+ screen.completeResultSP(customer.getAccount(withdrawAccount), transferUser.getAccount(depositAccount));
+ }
+}
diff --git a/src/main/java/Savings.java b/src/main/java/Savings.java
new file mode 100644
index 0000000..e411110
--- /dev/null
+++ b/src/main/java/Savings.java
@@ -0,0 +1,20 @@
+public class Savings extends Account{
+
+ public Savings(Integer accountNumber, double balance) {
+ super(accountNumber, balance);
+ }
+
+ public void transferToChecking(Checking checkingAccount, double transferAmount) {
+ if (this.getBalance() >= transferAmount) {
+ this.withdraw(transferAmount);
+ checkingAccount.deposit(transferAmount);
+ }
+ }
+
+ public void transferToInvestment(Investment investmentAccount, double transferAmount) {
+ if (this.getBalance() >= transferAmount) {
+ this.withdraw(transferAmount);
+ investmentAccount.deposit(transferAmount);
+ }
+ }
+}
diff --git a/src/main/java/Workflow.java b/src/main/java/Workflow.java
new file mode 100644
index 0000000..6ed9df9
--- /dev/null
+++ b/src/main/java/Workflow.java
@@ -0,0 +1,162 @@
+public class Workflow {
+
+ Display d;
+ Console c;
+ String lastAction;
+ Double lastAmount;
+
+ public Workflow(){
+ d = new Display();
+ c = new Console();
+ lastAction = "";
+ lastAmount = 0.0;
+ }
+
+ public void errorSP(){
+ d.currentDisplaySP("\nImproper input. Please reread instructions.\n");
+ }
+
+ public void initialWelcomeSP(){
+ d.currentDisplaySP("\nWelcome to the ATM!\nATM maintained by Xiong, Mike, Hazel, and Lena\n\nAre you a new or returning user?\nEnter 1 for new, 2 for returning.");
+ }
+
+ public Integer getInput(){
+ return c.getIntegerInput("Enter your input:");
+ }
+
+
+
+ //include input for customername
+ public void newCustomerNameSP(){
+ d.currentDisplaySP("Enter 0 to return back to home page.");
+ }
+ public String getCustomerNameSP(){
+ return c.getStringInput(("\nEnter your name here"));
+ }
+
+ public void usernameTakenSP(){
+ d.currentDisplaySP("Username is already taken. Please try again.");
+ }
+ //initial opening of an account + deposit. double and string
+
+ public void newUserSP(){
+ d.currentDisplaySP("Input your username, then password twice.\nEnter 0 to return back to home page");
+ }
+
+ public void passwordMismatchSP(){
+ d.currentDisplaySP("\nPasswords do not match. Please try again.");
+ }
+
+ public void returningUserSP(){
+ d.currentDisplaySP("\nInput your username, then password.\nEnter 0 to return back to home page.");
+ }
+
+ public String getUserSP(){
+ String middleMan = c.getStringInput("\nEnter username:");
+ d.setTransactionHistory("History of user " + middleMan + "\n");
+ return middleMan;
+ }
+ public String getUserSP2(){
+ return c.getStringInput("\nEnter username:");
+
+ }
+
+ public String getPassSP(){
+ return c.getStringInput("Enter password:");
+ }
+
+ public String getNameSP(){
+ return "";
+ }
+
+ public void initialAccountOpen(){
+ //user input double and string
+ }
+
+
+
+ public void mainMenuSP(Customer customer){
+ d.currentDisplaySP("Welcome, " + customer.getCustomerName() + "! What do you want to do?\n" +
+ "\n" +
+ "Enter 0 to check account number\t\t\t\t\tEnter 1 to check balance\n" +
+ "Enter 2 to transfer\t\t\t\t\t\t\t\tEnter 3 to withdraw\n" +
+ "Enter 4 to deposit\t\t\t\t\t\t\t\tEnter 5 to open a new account\n" +
+ "Enter 6 to close an account\t\t\t\t\t\tEnter 7 to print transaction history\n" +
+ "Enter 8 to transfer to a different user\t\t\tEnter 9 to log out\n");
+ }
+
+ public int enterAccount(){
+ return c.getIntegerInput("Enter an account:");
+ }
+
+ public String enterAccountType(){
+ return c.getStringInputNotCaseSensitive("Enter an account:");
+ }
+
+ public void checkPromptSP(){
+ d.currentDisplaySP("What account do you want to check?");
+ }
+
+ public void checkResultSP(Account account){
+ d.currentDisplaySP("Your account's current balance is " + account.getBalance());
+ }
+
+ public void withdrawPromptSP(){
+ d.currentDisplaySP("What account do you want to withdraw from?");
+ lastAction = " withdrawn from ";
+ }
+
+ public void depositPromptSP(){
+ d.currentDisplaySP("What account do you want to deposit into?");
+ lastAction = " deposited into ";
+ }
+
+ public void transferPromptSP(){
+ d.currentDisplaySP("What accounts do you want to transfer from and to?");
+ lastAction = " transferred from ";
+ }
+
+ public void transfer2UserPromptSP(){
+ d.currentDisplaySP("What account do you want to transfer to?");
+ lastAction = " transferred from ";
+ }
+
+ public Double amountPromptSP(){
+ //try catch
+ lastAmount = c.getDoubleInput("Transaction amount:");
+ return lastAmount;
+ }
+
+ public void completeResultSP(Account account){
+ d.currentDisplaySP("Action performed successfully.\n");
+ d.addToTransactionHistory(String.format("$ %s %s account #%s\n", lastAmount, lastAction, account.getAccountNumber()));
+ }
+
+ public void completeResultSP(Account account1, Account account2){
+ d.currentDisplaySP("Action performed successfully.\n");
+ d.addToTransactionHistory("$" + lastAmount + lastAction + "account #" + account1.getAccountNumber() + " to account #" + account2.getAccountNumber() + "\n");
+ }
+
+ public void completeResultsNoHistorySP(){
+ d.currentDisplaySP("Action performed successfully.\n");
+ }
+
+ public String openPrompt(){
+ return c.getStringInputNotCaseSensitive("What kind of account do you want to open?");
+ }
+
+ public void closePrompt(){
+ d.currentDisplaySP("What account do you want to close?\nNOTE: The account must be empty.");
+ }
+
+ public void printHistory(){
+ d.printTransactionHistory();
+ }
+
+ public void logOutSP(){
+ d.currentDisplaySP("Thank you for your business.");
+ d.setTransactionHistory("");
+ }
+
+}
+
diff --git a/src/main/test/AccountTest.java b/src/main/test/AccountTest.java
deleted file mode 100644
index cbea4ad..0000000
--- a/src/main/test/AccountTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import static org.junit.Assert.assertEquals;
-
-
-// Test the expected Account class from ATM.
-public class AccountTest {
-
- @Test
- public void testA0() {
- Account a = new Account(0.0);
- assertEquals(0.0, a.balance(), 0.0001);
- }
-
- @Test
- public void testA00() {
- Account a = new Account(10.0);
- assertEquals(10.0, a.balance(), 0.0001);
- }
-
- @Test
- public void testA01() {
- Account a = new Account(0.0);
- assertEquals(true, a.closeAccount());
- }
-
- @Test
- public void testA02() {
- Account a = new Account(10.0);
- assertEquals(false, a.closeAccount());
- }
-
- @Test
- public void testA1() {
- Account a = new Account(0.0);
- a.deposit(100.0);
- assertEquals(100.0, a.balance(), 0.0001);
- }
-
- @Test
- public void testA2() {
- Account a = new Account(10.0);
- a.deposit(100.0);
- assertEquals(110.0, a.balance(), 0.0001);
- }
-
- @Test
- public void testA3() {
- Account a = new Account(200.0);
- Double actual = a.withdraw(100.0);
- assertEquals(100.0, actual, 0.0001);
- }
-
- @Test
- public void testA4() {
- Account a = new Account(0.0);
- Double actual = a.withdraw(1.0);
- assertEquals(0.0, actual, 0.0001);
- }
-
- @Test
- public void testA5() {
- Account a = new Account(10.0);
- Account b = new Account(0.0);
- a.transfer(b, 10.0);
- assertEquals(0.0, a.balance(), 0.0001);
- assertEquals(10.0, b.balance(), 0.0001);
- }
-
- @Test
- public void testA6() {
- Account a = new Account(10.0);
- Account b = new Account(0.0);
- a.transfer(b, 100.0); // nothing should happen
- assertEquals(10.0, a.balance(), 0.0001);
- assertEquals(0.0, b.balance(), 0.0001);
- }
-
-
-}
diff --git a/src/main/test/WorkflowTest.java b/src/main/test/WorkflowTest.java
new file mode 100644
index 0000000..b9a4a60
--- /dev/null
+++ b/src/main/test/WorkflowTest.java
@@ -0,0 +1,22 @@
+import org.junit.Test;
+
+public class WorkflowTest {
+
+ @Test
+ public void Test1() {
+
+ Workflow w = new Workflow();
+
+ Account acct = new Savings(12, 34.0);
+ Account[] accts = new Account[1];
+ accts[0] = acct;
+ Customer customer = new Customer("Hazel", "HD", "45", accts);
+
+ String user = w.getUserSP();
+ w.mainMenuSP(customer);
+ w.withdrawPromptSP();
+ Double dub1 = w.amountPromptSP();
+ w.completeResultSP(accts[0]);
+ w.printHistory();
+ }
+}
diff --git a/src/main/test/java/CheckingTest.java b/src/main/test/java/CheckingTest.java
new file mode 100644
index 0000000..363681d
--- /dev/null
+++ b/src/main/test/java/CheckingTest.java
@@ -0,0 +1,104 @@
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class CheckingTest {
+
+ @Test
+ public void testConstructor() {
+ // : Given
+ Integer accountChecking = 14104244;
+ double initialDeposit = 1000.00;
+
+ // : When
+ Checking checking101 = new Checking(accountChecking, initialDeposit);
+ Integer actualAccountNumber = checking101.getAccountNumber();
+ double actualBalance = checking101.getBalance();
+
+ // : Then
+ Assert.assertEquals(accountChecking, actualAccountNumber);
+ Assert.assertEquals(initialDeposit, actualBalance, 0.00001);
+ }
+
+ @Test
+ public void testWithdraw() {
+ // : Given
+ Integer accountChecking = 14104244;
+ double initialDeposit = 1000.00;
+ Checking checking101 = new Checking(accountChecking, initialDeposit);
+
+ // : When
+ checking101.withdraw(750);
+ double expected = 250.00;
+ double actual = checking101.getBalance();
+
+ // : Then
+ Assert.assertEquals(expected, actual, 0.00001);
+ }
+
+ @Test
+ public void testDeposit() {
+ // : Given
+ Integer accountChecking = 14104244;
+ double initialDeposit = 1000.00;
+ Checking checking101 = new Checking(accountChecking, initialDeposit);
+
+ // : When
+ checking101.deposit(750);
+ double expected = 1750.00;
+ double actual = checking101.getBalance();
+
+ // : Then
+ Assert.assertEquals(expected, actual, 0.00001);
+ }
+
+ @Test
+ public void testTransferToSavings() {
+ // : Given
+ Integer accountChecking = 14104244;
+ Integer accountSavings = 160811456;
+ double initialDeposit = 1000.00;
+ Checking checking101 = new Checking(accountChecking, initialDeposit);
+ Savings savings101 = new Savings(accountSavings, initialDeposit);
+
+ // : When
+ double expectedCheckingBalance = 800;
+ double expectedSavingsBalance = 1200;
+ checking101.transferToSavings(savings101, 200);
+ double actualCheckingBalance = checking101.getBalance();
+ double actualSavingsBalance = savings101.getBalance();
+
+ System.out.println(checking101.getBalance());
+ System.out.println(savings101.getBalance());
+
+ // : Then
+ Assert.assertEquals(expectedCheckingBalance, actualCheckingBalance, 0.000001);
+ Assert.assertEquals(expectedSavingsBalance, actualSavingsBalance, 0.000001);
+ }
+
+ @Test
+ public void transferToInvestment() {
+ // : Given
+ Integer accountChecking = 14104244;
+ Integer accountInvestment = 18095386;
+ double initialCheckingDeposit = 1000.00;
+ double initialInvestmentDeposit = 50000;
+ Checking checking101 = new Checking(accountChecking, initialCheckingDeposit);
+ Investment investment101 = new Investment(accountInvestment, initialInvestmentDeposit);
+
+ // : When
+ double expectedCheckingBalance = 200;
+ double expectedInvestmentBalance = 50800;
+ checking101.transferToInvestment(investment101, 800);
+ double actualCheckingBalance = checking101.getBalance();
+ double actualInvestmentBalance = investment101.getBalance();
+
+ System.out.println(checking101.getBalance());
+ System.out.println(investment101.getBalance());
+
+ // : Then
+ Assert.assertEquals(expectedCheckingBalance, actualCheckingBalance, 0.000001);
+ Assert.assertEquals(expectedInvestmentBalance, actualInvestmentBalance, 0.000001);
+ }
+}
\ No newline at end of file
diff --git a/src/main/test/java/CreatorTest.java b/src/main/test/java/CreatorTest.java
new file mode 100644
index 0000000..3745b7b
--- /dev/null
+++ b/src/main/test/java/CreatorTest.java
@@ -0,0 +1,82 @@
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class CreatorTest {
+
+ @Test
+ public void createChecking() {
+ // : Given
+ double initialDeposit = 5000;
+
+ // : When
+ Checking checking101 = Creator.createChecking(initialDeposit);
+ double actualBalance = checking101.getBalance();
+
+ System.out.println(checking101.getAccountNumber());
+ System.out.println(checking101.getBalance());
+
+ // : Then
+ Assert.assertEquals(initialDeposit, actualBalance, 0.00001);
+ Assert.assertTrue(checking101.getAccountNumber() <= 999 & checking101.getAccountNumber() >= 100);
+ }
+
+ @Test
+ public void createSavings() {
+ // : Given
+ double initialDeposit = 25000;
+
+ // : When
+ Savings savings101 = Creator.createSavings(initialDeposit);
+ double actualBalance = savings101.getBalance();
+
+ System.out.println(savings101.getAccountNumber());
+ System.out.println(savings101.getBalance());
+
+ // : Then
+ Assert.assertEquals(initialDeposit, actualBalance, 0.00001);
+ Assert.assertTrue(savings101.getAccountNumber() <= 9999 & savings101.getAccountNumber() >= 1000);
+ }
+
+ @Test
+ public void createInvestment() {
+ // : Given
+ double initialDeposit = 50000;
+
+ // : When
+ Investment investment101 = Creator.createInvestment(initialDeposit);
+ double actualBalance = investment101.getBalance();
+
+ System.out.println(investment101.getAccountNumber());
+ System.out.println(investment101.getBalance());
+
+ // : Then
+ Assert.assertEquals(initialDeposit, actualBalance, 0.00001);
+ Assert.assertTrue(investment101.getAccountNumber() <= 99999 & investment101.getAccountNumber() >= 10000);
+ }
+
+ @Test
+ public void createCustomer() {
+ // : Given
+ String name = "Bruce Wayne";
+ String userName = "Batman";
+ String password = "Gotham";
+ Checking checking101 = Creator.createChecking(500);
+ Savings savings101 = Creator.createSavings(2500);
+ Investment investment101 = Creator.createInvestment(5000);
+
+ // : When
+ Customer bruce = Creator.createCustomer(name, userName, password, checking101, savings101, investment101);
+ String actualName = bruce.getCustomerName();
+ String actualUserName = bruce.getUserName();
+ String actualPassword = bruce.getPassword();
+
+ System.out.println(bruce.getAccountNumber());
+
+ // : Then
+ Assert.assertEquals(name, actualName);
+ Assert.assertEquals(userName, actualUserName);
+ Assert.assertEquals(password, actualPassword);
+ }
+}
\ No newline at end of file
diff --git a/src/main/test/java/CustomerTest.java b/src/main/test/java/CustomerTest.java
new file mode 100644
index 0000000..9472ba3
--- /dev/null
+++ b/src/main/test/java/CustomerTest.java
@@ -0,0 +1,209 @@
+import org.junit.Assert;
+import org.junit.Test;
+
+public class CustomerTest {
+
+ @Test
+ public void customerConstuctor() {
+ // : Given
+ String customerName = "Xiong Yuan";
+ String userName = "xyuan";
+ String password = "zipcode0";
+ Account checkingAccount = new Checking(24231, 23142);
+ Account savingsAccount = new Savings(111, 25000);
+
+ // : When
+ Customer xiong = new Customer(customerName, userName, password, checkingAccount, savingsAccount);
+ String actualName = xiong.getCustomerName();
+ String actualUserName = xiong.getUserName();
+ String actualPassword = xiong.getPassword();
+ String account = "Accounts: \n1 : 24231\n2 : 111\n";
+ String actualAccount = xiong.getAccountNumber();
+
+ // : Then
+ Assert.assertEquals(customerName, actualName);
+ Assert.assertEquals(userName, actualUserName);
+ Assert.assertEquals(password, actualPassword);
+ Assert.assertEquals(account, actualAccount);
+
+ }
+
+
+ @Test
+ public void getCustomerName() {
+ // : Given
+ String customerName = "Lena Litouka";
+ String userName = "llitouka";
+ String password = "zipcode0";
+ Account checkingAccount = new Checking(23142, 23214);
+ Account[] accounts = new Account[]{checkingAccount};
+ // : When
+ Customer lena = new Customer(customerName, userName, password, accounts);
+ String actualName = lena.getCustomerName();
+
+ // : Then
+ Assert.assertEquals(customerName, actualName);
+
+ }
+ @Test
+ public void setCustomerName() {
+ // : Given
+ String customerName = "Liam Becker";
+ String userName = "hbecker";
+ String password = "zipcode0";
+ Account checkingAccount = new Checking(22456, 25631);
+ Account[] accounts = new Account[]{checkingAccount};
+ // : When
+ Customer hazel = new Customer(customerName, userName, password, accounts);
+ hazel.setCustomerName("Hazel Becker");
+ String expected = "Hazel Becker";
+ String actualName = hazel.getCustomerName();
+ // : Then
+ Assert.assertEquals(expected, actualName);
+ }
+
+ @Test
+ public void getUserName() {
+ // : Given
+ String customerName = "Mike Ninh";
+ String userName = "DynoMike";
+ String password = "zipcode0";
+ Account checkingAccount = new Checking(26226, 12956);
+ Account[] accounts = new Account[]{checkingAccount};
+ // : When
+ Customer mike = new Customer(customerName, userName, password, accounts);
+ String actualName = mike.getUserName();
+ // : Then
+ Assert.assertEquals(userName, actualName);
+ }
+
+ @Test
+ public void setUserName() {
+ String customerName = "Ask Ketchum";
+ String userName = "WannaPokemonMaster";
+ String password = "BeTheVeryBest";
+ Account checkingAccount = new Checking(34113, 1000);
+ Account[] accounts = new Account[]{checkingAccount};
+ // : When
+ Customer ketchumAll = new Customer(customerName, userName, password, accounts);
+ ketchumAll.setUserName("PokemonMaster");
+ String expected = "PokemonMaster";
+ String actualName = ketchumAll.getUserName();
+ // : Then
+ Assert.assertEquals(expected, actualName);
+ }
+
+ @Test
+ public void getPassWord() {
+ String customerName = "Tony Stark";
+ String userName = "IronMan";
+ String password = "zipcode0";
+ Account checkingAccount = new Checking(12402, 923132956);
+ Account[] accounts = new Account[]{checkingAccount};
+ // : When
+ Customer stark = new Customer(customerName, userName, password, accounts);
+ String actualpassword = stark.getPassword();
+ // : Then
+ Assert.assertEquals(password, actualpassword);
+ }
+
+ @Test
+ public void setPassWord() {
+ String customerName = "";
+ String userName = "";
+ String password = "";
+ Account checkingAccount = new Checking(22456, 25631);
+ Account[] accounts = new Account[]{checkingAccount};
+ // : When
+ Customer test = new Customer(customerName, userName, password, accounts);
+ test.setPassword("spotholder");
+ String expectedPW = "spotholder";
+ String actualPW = test.getPassword();
+ // : Then
+ Assert.assertEquals(expectedPW, actualPW);
+ }
+
+ @Test
+ public void getAccountNumber() {
+ // : Given
+ String customerName = "Bruce Wayne";
+ String userName = "NotBatman";
+ String password = "zipcode0";
+ Account checkingAccount = new Checking(32563, 915252956);
+ Account savingsAccount = new Savings(992223, 750);
+ Account investAccount = new Investment(111, 50000);
+ Account[] accounts = new Account[]{checkingAccount, savingsAccount, investAccount};
+ // : When
+ String account = "Accounts: \n1 : 32563\n" + "2 : 992223\n" + "3 : 111\n";
+ Customer wayne = new Customer(customerName, userName, password, accounts);
+ String actualAccount = wayne.getAccountNumber();
+
+ System.out.println(actualAccount);
+ // : Then
+ Assert.assertEquals(account, actualAccount);
+ }
+
+ @Test
+ public void addAccountTest() {
+ // : Given
+ String customerName = "Bruce Wayne";
+ String userName = "NotBatman";
+ String password = "zipcode0";
+ Account checkingAccount = new Checking(32563, 915252956);
+ Customer wayne = new Customer(customerName, userName, password, checkingAccount);
+
+ // : When
+ Account savingsAccount = Creator.createSavings(5000);
+ wayne.addAccount(savingsAccount);
+ int expected = 2;
+ int actual = wayne.getNumberOfAccounts();
+
+ // : Then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testCloseAccountWithBalance() {
+ // : Given
+ String customerName = "Bruce Wayne";
+ String userName = "NotBatman";
+ String password = "zipcode0";
+ Account checkingAccount = new Checking(32563, 915252956);
+ Account savingsAccount = new Savings(992223, 750);
+ Account investAccount = new Investment(111, 50000);
+ Account[] accounts = new Account[]{checkingAccount, savingsAccount, investAccount};
+ // : When
+ String account = "Accounts: \n1 : 32563\n" + "2 : 992223\n" + "3 : 111\n";
+ Customer wayne = new Customer(customerName, userName, password, accounts);
+ wayne.getAccount(111).withdraw(10000);
+ wayne.closeAccount(111);
+ String actualAccount = wayne.getAccountNumber();
+
+ System.out.println(actualAccount);
+ // : Then
+ Assert.assertEquals(account, actualAccount);
+ }
+
+ @Test
+ public void testCloseAccountWithNoBalance() {
+ // : Given
+ String customerName = "Bruce Wayne";
+ String userName = "NotBatman";
+ String password = "zipcode0";
+ Account checkingAccount = new Checking(32563, 915252956);
+ Account savingsAccount = new Savings(992223, 750);
+ Account investAccount = new Investment(111, 50000);
+ Account[] accounts = new Account[]{checkingAccount, savingsAccount, investAccount};
+ // : When
+ String account = "Accounts: \n1 : 32563\n" + "2 : 992223\n";
+ Customer wayne = new Customer(customerName, userName, password, accounts);
+ wayne.getAccount(111).withdraw(50000);
+ wayne.closeAccount(111);
+ String actualAccount = wayne.getAccountNumber();
+
+ System.out.println(actualAccount);
+ // : Then
+ Assert.assertEquals(account, actualAccount);
+ }
+
+}
diff --git a/src/main/test/java/DatabaseTest.java b/src/main/test/java/DatabaseTest.java
new file mode 100644
index 0000000..144fe45
--- /dev/null
+++ b/src/main/test/java/DatabaseTest.java
@@ -0,0 +1,115 @@
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class DatabaseTest {
+
+ @Test
+ public void addCustomerTest() {
+ // : Given
+ Checking bruceChecking = Creator.createChecking(100);
+ Savings bruceSaving = Creator.createSavings(500);
+ Customer bruce = Creator.createCustomer("Bruce", "Bat", "Gotham", bruceChecking, bruceSaving);
+
+ // : When
+ Database.removeAllCustomers();
+ Database.addCustomer(bruce);
+ int expected = 1;
+ int actual = Database.getNumberOfCustomers();
+
+ System.out.println(Database.getNumberOfCustomers());
+
+ // : Then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getCustomerByNameTest() {
+ Checking bruceChecking = Creator.createChecking(100);
+ Savings bruceSaving = Creator.createSavings(500);
+ Checking batmanChecking = Creator.createChecking(500);
+ Savings batmanSavings = Creator.createSavings(1000);
+ Customer bruce = Creator.createCustomer("Bruce", "Bat", "Gotham", bruceChecking, bruceSaving);
+ Customer batman = Creator.createCustomer("Batman", "h", "y", batmanChecking, batmanSavings);
+
+ // : When
+ Database.removeAllCustomers();
+ Database.addCustomer(bruce);
+ Database.addCustomer(batman);
+ Customer expected = batman;
+ Customer actual = Database.getCustomerByName("Batman");
+
+ System.out.println(Database.getNumberOfCustomers());
+
+ // : Then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getCustomerByUsernameTest() {
+ Checking bruceChecking = Creator.createChecking(100);
+ Savings bruceSaving = Creator.createSavings(500);
+ Checking batmanChecking = Creator.createChecking(500);
+ Savings batmanSavings = Creator.createSavings(1000);
+ Customer bruce = Creator.createCustomer("Bruce", "Bat", "Gotham", bruceChecking, bruceSaving);
+ Customer batman = Creator.createCustomer("Batman", "h", "y", batmanChecking, batmanSavings);
+
+ // : When
+ Database.removeAllCustomers();
+ Database.addCustomer(bruce);
+ Database.addCustomer(batman);
+ Customer expected = batman;
+ Customer actual = Database.getCustomerByUsername("h");
+
+ System.out.println(Database.getNumberOfCustomers());
+
+ // : Then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void removeCustomerTest() {
+ Checking bruceChecking = Creator.createChecking(100);
+ Savings bruceSaving = Creator.createSavings(500);
+ Checking batmanChecking = Creator.createChecking(500);
+ Savings batmanSavings = Creator.createSavings(1000);
+ Customer bruce = Creator.createCustomer("Bruce", "Bat", "Gotham", bruceChecking, bruceSaving);
+ Customer batman = Creator.createCustomer("Batman", "h", "y", batmanChecking, batmanSavings);
+
+ // : When
+ Database.removeAllCustomers();
+ Database.addCustomer(bruce);
+ Database.addCustomer(batman);
+ Database.removeCustomer(bruce);
+ int expected = 1;
+ int actual = Database.getNumberOfCustomers();
+
+ System.out.println(Database.getNumberOfCustomers());
+
+ // : Then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void removeAllCustomersTest() {
+ Checking bruceChecking = Creator.createChecking(100);
+ Savings bruceSaving = Creator.createSavings(500);
+ Checking batmanChecking = Creator.createChecking(500);
+ Savings batmanSavings = Creator.createSavings(1000);
+ Customer bruce = Creator.createCustomer("Bruce", "Bat", "Gotham", bruceChecking, bruceSaving);
+ Customer batman = Creator.createCustomer("Batman", "h", "y", batmanChecking, batmanSavings);
+
+ // : When
+ Database.addCustomer(bruce);
+ Database.addCustomer(batman);
+ Database.removeAllCustomers();
+ int expected = 0;
+ int actual = Database.getNumberOfCustomers();
+
+ System.out.println(Database.getNumberOfCustomers());
+
+ // : Then
+ Assert.assertEquals(expected, actual);
+ }
+}
\ No newline at end of file
diff --git a/src/main/test/java/InvestmentTest.java b/src/main/test/java/InvestmentTest.java
new file mode 100644
index 0000000..514e07b
--- /dev/null
+++ b/src/main/test/java/InvestmentTest.java
@@ -0,0 +1,108 @@
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class InvestmentTest {
+ @Test
+ public void testConstructor() {
+ // : Given
+ Integer expectedAccountNumber = 777777777;
+ Double expectedBalance = 1200.0;
+ Investment investmentZero=new Investment(expectedAccountNumber,expectedBalance);
+
+ // : When
+
+ Integer actualAccountNumber=investmentZero.getAccountNumber();
+ double actualBalance=investmentZero.getBalance();
+
+ // : Then
+ Assert.assertEquals(expectedAccountNumber,actualAccountNumber);
+ Assert.assertEquals(expectedBalance,actualBalance,0.00001);
+ }
+
+ @Test
+ public void testDepositToInvestment() {
+ // : Given
+ Integer investementAccountNumber = 888888888;
+ double investmentAccountBalance = 9000.0;
+ Investment investmentZero=new Investment(investementAccountNumber,investmentAccountBalance);
+
+ // : When
+ investmentZero.deposit(1000.0);
+ double expectedInvestmentAccountBalance=10000.0;
+ double actualInvestmentAccountBalance=investmentZero.getBalance();
+ System.out.println(actualInvestmentAccountBalance);
+
+ // : Then
+ Assert.assertEquals(expectedInvestmentAccountBalance,actualInvestmentAccountBalance, 0.000001);
+ }
+
+ @Test
+ public void testWithdrawFromInvestment() {
+ // : Given
+ Integer investementAccountNumber = 888888888;
+ double investmentAccountBalance = 9000.0;
+ Investment investmentZero=new Investment(investementAccountNumber,investmentAccountBalance);
+
+ // : When
+ investmentZero.withdraw(2000.0);
+ double expectedInvestmentAccountBalance=7000.0;
+ double actualInvestmentAccountBalance=investmentZero.getBalance();
+ System.out.println(actualInvestmentAccountBalance);
+
+ // : Then
+ Assert.assertEquals(expectedInvestmentAccountBalance,actualInvestmentAccountBalance, 0.00001);
+ }
+
+ @Test
+ public void testTransferToSavings() {
+ // : Given
+ Integer investementAccountNumber = 777777777;
+ double investmentAccountBalance = 12000.0;
+ Integer savingsAccountNumber =11111111;
+ double savingsAccountBalance=7000.0;
+ Investment investmentZero=new Investment(investementAccountNumber,investmentAccountBalance);
+ Savings savingsZero=new Savings(savingsAccountNumber,savingsAccountBalance);
+
+ // : When
+ double transferAmountToSaving=3000.0;
+ double expectedInvestmentAccountBalance=9000.0;
+ double expectedSavingsAccountBalance=10000.0;
+ investmentZero.transferToSavings(savingsZero,transferAmountToSaving);
+ double actualInvestmentAccountBalance=investmentZero.getBalance();
+ double actualSavigsAccountBalance=savingsZero.getBalance();
+
+ System.out.println(investmentZero.getBalance());
+ System.out.println(savingsZero.getBalance());
+
+ // : Then
+ Assert.assertEquals(expectedInvestmentAccountBalance,actualInvestmentAccountBalance,0.0000001);
+ Assert.assertEquals(expectedSavingsAccountBalance,actualSavigsAccountBalance, 0.000001);
+ }
+
+ @Test
+ public void testTransferToChecking() {
+ // : Given
+ Integer investementAccountNumber = 888888888;
+ double investmentAccountBalance = 9000.0;
+ Integer checkingAccountNumber =00077777666;
+ double checkingAccountBalance=5000.0;
+ Investment investmentZero=new Investment(investementAccountNumber,investmentAccountBalance);
+ Checking checkingZero=new Checking(checkingAccountNumber,checkingAccountBalance);
+ // : When
+ double transferAmountToChecking=500.0;
+ double expectedInvestmentAccountBalance=8500.0;
+ double expectedCheckingAccountBalance=5500.0;
+ investmentZero.transferToChecking(checkingZero,transferAmountToChecking);
+ double actualInvestmentAccountBalance=investmentZero.getBalance();
+ double actualCheckingAccountBalance=checkingZero.getBalance();
+
+ System.out.println(investmentZero.getBalance());
+ System.out.println(checkingZero.getBalance());
+
+
+ // : Then
+ Assert.assertEquals(expectedInvestmentAccountBalance,actualInvestmentAccountBalance,0.0000001);
+ Assert.assertEquals(expectedCheckingAccountBalance,actualCheckingAccountBalance, 0.000001);
+ }
+}
\ No newline at end of file
diff --git a/src/main/test/java/SavingsTest.java b/src/main/test/java/SavingsTest.java
new file mode 100644
index 0000000..dba9eb1
--- /dev/null
+++ b/src/main/test/java/SavingsTest.java
@@ -0,0 +1,110 @@
+import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SavingsTest {
+
+ @Test
+ public void testSavingsAccount() {
+ // : Given
+ Integer savingsAccountNumber=9999999;
+ double savingsAccountBalance=1300.0;
+ Savings savingsZero=new Savings(savingsAccountNumber,savingsAccountBalance);
+ // : When
+
+ Integer actualSavingsAccountNumber=savingsZero.getAccountNumber();
+ double actualSavingsAccountBalance=savingsZero.getBalance();
+
+ // : Then
+ Assert.assertEquals(savingsAccountNumber,actualSavingsAccountNumber, 0.00001);
+ Assert.assertEquals(savingsAccountBalance,actualSavingsAccountBalance, 0.00001);
+ }
+
+ @Test
+ public void testDepositToSavings() {
+ // : Given
+ Integer savingsAccountNumber = 888888888;
+ double savingsAccountBalance = 7000.0;
+ Savings savingsZero=new Savings(savingsAccountNumber,savingsAccountBalance);
+
+ // : When
+ savingsZero.deposit(100.0);
+ double expectedSavingsAccountBalance=7100.0;
+ double actualSavingsAccountBalance=savingsZero.getBalance();
+ System.out.println(actualSavingsAccountBalance);
+
+ // : Then
+ Assert.assertEquals(expectedSavingsAccountBalance,actualSavingsAccountBalance, 0.000001);
+ }
+
+ @Test
+ public void testWithdrawFromSavings() {
+ // : Given
+ Integer savingsAccountNumber = 888888888;
+ double savingsAccountBalance = 9000.0;
+ Savings savingsZero=new Savings(savingsAccountNumber,savingsAccountBalance);
+
+ // : When
+ savingsZero.withdraw(6000.0);
+ double expectedSavingsAccountBalance=3000.0;
+ double actualSavingsAccountBalance=savingsZero.getBalance();
+ System.out.println(actualSavingsAccountBalance);
+
+ // : Then
+ Assert.assertEquals(expectedSavingsAccountBalance, actualSavingsAccountBalance,0.00001);
+ }
+
+ @Test
+ public void testTransferToCheckingAccount() {
+ // : Given
+ Integer savingsAccountNumber = 343234321;
+ double savingsAccountBalance = 0.0;
+ Integer checkingAccountNumber =89898998;
+ double checkingAccountBalance=8000.0;
+ Checking checkingZero=new Checking(checkingAccountNumber,checkingAccountBalance);
+ Savings savingsZero=new Savings(savingsAccountNumber,savingsAccountBalance);
+
+ // : When
+ double transferAmountToChecking=3000.0;
+ double expectedCheckingAccountBalance=8000.0;
+ double expectedSavingsAccountBalance=0.0;
+ savingsZero.transferToChecking(checkingZero,transferAmountToChecking);
+ double actualCheckingAccountBalance=checkingZero.getBalance();
+ double actualSavigsAccountBalance=savingsZero.getBalance();
+
+ System.out.println(checkingZero.getBalance());
+ System.out.println(savingsZero.getBalance());
+
+ // : Then
+ Assert.assertEquals(expectedCheckingAccountBalance,actualCheckingAccountBalance,0.0000001);
+ Assert.assertEquals(expectedSavingsAccountBalance,actualSavigsAccountBalance, 0.000001);
+
+ }
+
+ @Test
+ public void testTransferToInvestment() {
+ // : Given
+ Integer savingsAccountNumber = 7777777;
+ double savingsAccountBalance = 6000.0;
+ Integer investementAccountNumber = 5555555;
+ double investmentAccountBalance = 1000.0;
+ Savings savingsZero=new Savings(savingsAccountNumber,savingsAccountBalance);
+ Investment investmentZero=new Investment(investementAccountNumber,investmentAccountBalance);
+
+ // : When
+ double transferAmountToInvestment=500.0;
+ double expectedInvestmentAccountBalance=1500.0;
+ double expectedSavingsAccountBalance=5500.0;
+ savingsZero.transferToInvestment(investmentZero,transferAmountToInvestment);
+ double actualInvestmentAccountBalance=investmentZero.getBalance();
+ double actualSavingsAccountBalance=savingsZero.getBalance();
+
+ System.out.println(investmentZero.getBalance());
+ System.out.println(savingsZero.getBalance());
+
+
+ // : Then
+ Assert.assertEquals(expectedInvestmentAccountBalance,actualInvestmentAccountBalance,0.0000001);
+ Assert.assertEquals(expectedSavingsAccountBalance,actualSavingsAccountBalance, 0.000001);
+ }
+}
\ No newline at end of file
diff --git a/src/uml.puml b/src/uml.puml
new file mode 100644
index 0000000..116d6e7
--- /dev/null
+++ b/src/uml.puml
@@ -0,0 +1,60 @@
+@startuml
+
+class MainApplication{
+ run();
+}
+
+class Customer{
+ Map credentials;
+ ArrayList ownedAccounts;
+ String name;
+
+ createUser();
+}
+
+class Display{
+ String currentDisplay;
+ String menu;
+ String transactionHistory;
+
+ //getters and setters();
+}
+
+class Console{
+ getDoubleInput(Double);
+ getStringInput(String);
+}
+
+abstract class Account{
+ Map cashMoneys;
+ Double currentBalance;
+ Integer accountNumber;
+
+ openNewAccount(Integer);
+ //getters and setters();
+}
+
+class Transactions{
+ getBalance();
+ transfer(Double);
+ withdraw(Double);
+ closeAccount(Integer);
+}
+
+class Investment{
+ //inherits stuff
+}
+
+class Savings{
+ //inherits stuff
+}
+
+class Checking{
+ //inherits stuff
+}
+
+Account <|-- Investment
+Account <|-- Savings
+Account <|-- Checking
+
+@enduml
\ No newline at end of file