MainApplication.java 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. package com.zipcodewilmington.bankaccountlab;
  2. import com.sun.tools.javac.comp.Check;
  3. import sun.applet.Main;
  4. import java.util.Scanner;
  5. /**
  6. * Created by leon on 1/10/18.
  7. */
  8. public class MainApplication {
  9. private String name;
  10. private String email;
  11. private String address;
  12. private int pin;
  13. private boolean runCommandCenter;
  14. private CheckingAccount checkingAccount;
  15. private BusinessAccount businessAccount;
  16. private SavingsAccount savingsAccount;
  17. Atm atm = new Atm();
  18. public void main(String[] vv) {
  19. while(runCommandCenter){
  20. commandCenter();
  21. }
  22. System.out.println("Baller ATM only...");
  23. MainApplication mainApplication = new MainApplication(name, email, address, pin);
  24. }
  25. public MainApplication(String name, String email, String address, int pin) {
  26. long accountNumber = Math.round(Math.random() * 999999999);
  27. double balance = 00000.00;
  28. createBusinessAccount(name, email, address, pin, accountNumber, balance);
  29. createSavingsAccount(name, email, address, pin, accountNumber, balance);
  30. createCheckingAccount(name, email, address, pin, accountNumber, balance);
  31. }
  32. public void commandCenter(){
  33. Scanner scanner = new Scanner(System.in);
  34. System.out.println("Choose a command");
  35. 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");
  36. int userInput = scanner.nextInt();
  37. switch(userInput){
  38. case 1:
  39. System.out.println("Your Checking Account balance is: " + checkingAccount.getBalance());
  40. break;
  41. case 2:
  42. System.out.println("Your Savings Account balance is: " + savingsAccount.getBalance());
  43. break;
  44. case 3:
  45. System.out.println("Your Business Account balance is: " + businessAccount.getBalance());
  46. break;
  47. case 4:
  48. System.out.println("How much money would you like to deposit into your Checking Account?");
  49. atm.depositMoney(checkingAccount, scanner.nextDouble());
  50. System.out.println("Money deposited.");
  51. break;
  52. case 5:
  53. System.out.println("How much money would you like to deposit into your Savings Account?");
  54. atm.depositMoney(savingsAccount, scanner.nextDouble());
  55. System.out.println("Money deposited.");
  56. break;
  57. case 6:
  58. System.out.println("How much money would you like to deposit into your Business Account?");
  59. atm.depositMoney(businessAccount, scanner.nextDouble());
  60. System.out.println("Money deposited.");
  61. break;
  62. case 7:
  63. System.out.println("How much money would you like to withdraw from your Checking Account?");
  64. atm.withdrawMoney(checkingAccount, scanner.nextDouble());
  65. System.out.println("Money withdrawn.");
  66. break;
  67. case 8:
  68. System.out.println("How much money would you like to withdraw from your Savings Account?");
  69. atm.withdrawMoney(savingsAccount, scanner.nextDouble());
  70. System.out.println("Money withdrawn.");
  71. break;
  72. case 9:
  73. System.out.println("How much money would you like to withdraw from your Business Account?");
  74. atm.withdrawMoney(businessAccount, scanner.nextDouble());
  75. System.out.println("Money withdrawn");
  76. break;
  77. case 10:
  78. System.out.println("Enter a new pin number.");
  79. atm.changePin(businessAccount, scanner.nextInt());
  80. //might have to change all of the pin number individually...
  81. }
  82. }
  83. public CheckingAccount createCheckingAccount(String name, String email, String address, int pin, long accountNumber, double balance){
  84. CheckingAccount checkingAccount = new CheckingAccount(name, email, address, pin, accountNumber, balance);
  85. this.checkingAccount = checkingAccount;
  86. return this.checkingAccount;
  87. }
  88. public BusinessAccount createBusinessAccount(String name, String email, String address, int pin, long accountNumber, double balance){
  89. BusinessAccount businessAccount = new BusinessAccount(name, email, address, pin, accountNumber, balance);
  90. this.businessAccount = businessAccount;
  91. return this.businessAccount;
  92. }
  93. public SavingsAccount createSavingsAccount(String name, String email, String address, int pin, long accountNumber, double balance){
  94. SavingsAccount savingsAccount = new SavingsAccount(name, email, address, pin, accountNumber, balance);
  95. this.savingsAccount = savingsAccount;
  96. return this.savingsAccount;
  97. }
  98. }