| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- package com.zipcodewilmington.bankaccountlab;
-
- /**
- * Created by leon on 1/10/18.
- */
- public class BankAccount {
- BusinessAccount ba = new BusinessAccount();
- CheckingAccount ca = new CheckingAccount();
- SavingsAccount sa = new SavingsAccount();
- double amountToWithdraw;
- double currentAmount;
- double amountToDeposit;
- boolean isRunning = true;
-
- public BankAccount() {
- this.amountToWithdraw = amountToWithdraw;
- this.currentAmount = 4000;
- this.amountToDeposit = amountToDeposit;
- }
-
- public static void main(String[] args) {
- BankAccount bank = new BankAccount();
- bank.start();
- }
-
- public void start() {
- do {
- Console.print("Welcome to Tyler's ATM");
- String whichBankAccount = Console.stringPrompt("What bank account are you accessing today? Select either checking, Savings, or Business. Or type exit to exit.");
- if (whichBankAccount.equalsIgnoreCase("business")) {
- chooseBusinessAccount();
- } else if (whichBankAccount.equalsIgnoreCase("checking")) {
- chooseCheckingAccount();
- } else if (whichBankAccount.equalsIgnoreCase("savings")) {
- chooseSavingsAccount();
- } else {
- Console.print("Please select an option from the list.");
- }
-
- if(whichBankAccount.equalsIgnoreCase("exit")){
- isRunning = false;
- }
- } while(isRunning);
-
- }
-
- public void chooseAction() {
- String withdrawOrDeposit = Console.stringPrompt("Please choose either withdraw or deposit.");
- if (withdrawOrDeposit.equalsIgnoreCase("withdraw")) {
- double amountToWithdraw = Console.doublePrompt("How much money would you like to withdraw today?");
- Console.print("You now have $" + ba.withdraw(currentAmount, amountToWithdraw) + " in your bank account");
- } else if (withdrawOrDeposit.equalsIgnoreCase("deposit")) {
- double amountToDeposit = Console.doublePrompt("How much money would you like to deposit today?");
- Console.print("You now have $" + ba.deposit(currentAmount, amountToDeposit) + " in your bank account");
- } else {
- Console.print("Please choose an option from the list.");
- }
- }
-
- public void chooseBusinessAccount(){
- Console.doublePrompt("Please enter your pin number");
- Console.print("Your current balance is: $" + currentAmount);
- chooseAction();
- ba.withdraw(currentAmount, amountToWithdraw);
- ba.deposit(currentAmount, amountToDeposit);
- }
-
- public void chooseSavingsAccount(){
- Console.doublePrompt("Please enter your pin number");
- Console.print("Your current balance is: $" + currentAmount);
- chooseAction();
- ca.withdraw(currentAmount, amountToWithdraw);
- ca.deposit(currentAmount, amountToDeposit);
- }
-
- public void chooseCheckingAccount(){
- Console.doublePrompt("Please enter your pin number");
- Console.print("Your current balance is: $" + currentAmount);
- chooseAction();
- sa.withdraw(currentAmount, amountToWithdraw);
- sa.deposit(currentAmount, amountToDeposit);
- }
-
- }
|