package com.zipcodewilmington.bankaccountlab; import com.sun.tools.javac.comp.Check; import sun.applet.Main; import java.util.Scanner; /** * Created by leon on 1/10/18. */ public class MainApplication { private String name; private String email; private String address; private int pin; private boolean runCommandCenter; private CheckingAccount checkingAccount; private BusinessAccount businessAccount; private SavingsAccount savingsAccount; Atm atm = new Atm(); public void main(String[] vv) { while(runCommandCenter){ commandCenter(); } System.out.println("Baller ATM only..."); MainApplication mainApplication = new MainApplication(name, email, address, pin); } public MainApplication(String name, String email, String address, int pin) { long accountNumber = Math.round(Math.random() * 999999999); double balance = 00000.00; createBusinessAccount(name, email, address, pin, accountNumber, balance); createSavingsAccount(name, email, address, pin, accountNumber, balance); createCheckingAccount(name, email, address, pin, accountNumber, balance); } public void commandCenter(){ Scanner scanner = new Scanner(System.in); System.out.println("Choose a command"); System.out.println("'1' - Get the balance of your Checking Account \n'2' - Get the balance of your Savings Account \n'3' - Get balance of your Business Account\n'4' - Deposit money to your Checking Account\n'5' - Deposit money to your Savings Account\n'6' - Deposit money to your Business Account\n'7' - Withdraw money from your Checking Account\n'8' - Withdraw money from your Savings Account\n'9' - Withdraw money from your Business Account\n'10' - Change the pin of your accounts\n'11' - Transfer funds between accounts"); int userInput = scanner.nextInt(); switch(userInput){ case 1: System.out.println("Your Checking Account balance is: " + checkingAccount.getBalance()); break; case 2: System.out.println("Your Savings Account balance is: " + savingsAccount.getBalance()); break; case 3: System.out.println("Your Business Account balance is: " + businessAccount.getBalance()); break; case 4: System.out.println("How much money would you like to deposit into your Checking Account?"); atm.depositMoney(checkingAccount, scanner.nextDouble()); System.out.println("Money deposited."); break; case 5: System.out.println("How much money would you like to deposit into your Savings Account?"); atm.depositMoney(savingsAccount, scanner.nextDouble()); System.out.println("Money deposited."); break; case 6: System.out.println("How much money would you like to deposit into your Business Account?"); atm.depositMoney(businessAccount, scanner.nextDouble()); System.out.println("Money deposited."); break; case 7: System.out.println("How much money would you like to withdraw from your Checking Account?"); atm.withdrawMoney(checkingAccount, scanner.nextDouble()); System.out.println("Money withdrawn."); break; case 8: System.out.println("How much money would you like to withdraw from your Savings Account?"); atm.withdrawMoney(savingsAccount, scanner.nextDouble()); System.out.println("Money withdrawn."); break; case 9: System.out.println("How much money would you like to withdraw from your Business Account?"); atm.withdrawMoney(businessAccount, scanner.nextDouble()); System.out.println("Money withdrawn"); break; case 10: System.out.println("Enter a new pin number."); atm.changePin(businessAccount, scanner.nextInt()); //might have to change all of the pin number individually... } } public CheckingAccount createCheckingAccount(String name, String email, String address, int pin, long accountNumber, double balance){ CheckingAccount checkingAccount = new CheckingAccount(name, email, address, pin, accountNumber, balance); this.checkingAccount = checkingAccount; return this.checkingAccount; } public BusinessAccount createBusinessAccount(String name, String email, String address, int pin, long accountNumber, double balance){ BusinessAccount businessAccount = new BusinessAccount(name, email, address, pin, accountNumber, balance); this.businessAccount = businessAccount; return this.businessAccount; } public SavingsAccount createSavingsAccount(String name, String email, String address, int pin, long accountNumber, double balance){ SavingsAccount savingsAccount = new SavingsAccount(name, email, address, pin, accountNumber, balance); this.savingsAccount = savingsAccount; return this.savingsAccount; } }