Created
April 17, 2016 18:12
-
-
Save dante-byte/827c284735a612c2c8f6be7ac6946ff8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bank.of.atlanta; | |
import java.util.Scanner; | |
public class Bank { | |
public String bankName; | |
public double totalMoneyAtTheBank; | |
public BankAccount[] bankAcctList = new BankAccount[3]; | |
public void addBankAccount(BankAccount bankAcctToAdd, int bankAcctIndex) { | |
System.out.println("we will be adding a bank account"); | |
bankAcctList[bankAcctIndex] = bankAcctToAdd; | |
totalMoneyAtTheBank = totalMoneyAtTheBank + bankAcctToAdd.getBalance(); | |
} | |
public void printInfo() { | |
System.out.println("Name: " + bankName); | |
System.out.println("Total money in this bank: " + totalMoneyAtTheBank); | |
} | |
} | |
//BankAccounts[] allAccounts = new BankAccounts [3]; | |
//allAccounts[0] = ("BusinessCheckings"); | |
//allAccounts[1] = ("BusinessSavings"); | |
//allAccounts[2] = ("PersonalCheckings"); | |
//allAccounts[3] = ("PersonalSavings"); | |
//TotalMoneyAtBank = allAccounts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bank.of.atlanta; | |
import java.util.Scanner; | |
public class BankAccount { | |
public String name; | |
public double balance; | |
public double getBalance() { | |
return balance; | |
} | |
public void printInfo() { | |
System.out.println("====================="); | |
System.out.println("Account name: " + name); | |
System.out.println("Account balance: " + balance); | |
System.out.println("====================="); | |
} | |
public void deposit(double amountToDeposit) { | |
balance = balance + amountToDeposit; | |
} | |
public void withdraw(double amountToWithDraw) { | |
balance = balance - amountToWithDraw; | |
System.out.println("What amount would you like to withdraw"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bank.of.atlanta; | |
import java.util.Scanner; | |
//for (int counter = 0; counter < 4; counter++) {} | |
public class Day9Runner { | |
public static void getUserInputInloop() { | |
System.out.println("Finally - getting user input"); | |
for (int ifrun = 0; ifrun < 3; ifrun++) { | |
getUserInput(ifrun); | |
} | |
} | |
public static void getUserInput(int acctNum) { | |
System.out.println("Getting user input"); | |
Scanner myScanner = new Scanner(System.in); | |
System.out.println("What is the name of your current account #" + (acctNum+1) + "?"); | |
String currentAccountName = myScanner.nextLine(); | |
BankAccount currentAccount = new BankAccount(); | |
currentAccount.name = currentAccountName; | |
myBank.addBankAccount(currentAccount, acctNum); | |
myBank.printInfo(); | |
System.out.println("Thank you - creating " + currentAccountName + " for you"); | |
} | |
static Bank myBank = new Bank(); | |
public static void askUserQuestions() { | |
while (true) { | |
System.out.println("What account wouuld you like to use?"); | |
for (int acctIndex = 0; acctIndex < myBank.bankAcctList.length; | |
acctIndex++) { | |
System.out.println(acctIndex + " - " + myBank.bankAcctList[acctIndex].name); | |
} | |
Scanner accountChoiceScanner = new Scanner(System.in); | |
String accountChoice = accountChoiceScanner.nextLine(); | |
int acctIndex = Integer.parseInt(accountChoice); | |
BankAccount chosenAccount = myBank.bankAcctList[acctIndex]; | |
System.out.println("You have chosen your " + chosenAccount.name + "account"); | |
while (true) { | |
System.out.println("What would you like to do?"); | |
System.out.println("1. Deposit"); | |
System.out.println("2. Withdraw"); | |
System.out.println("3. Print Account Information"); | |
System.out.println("4. Print Bank Information"); | |
System.out.println("x. Exit"); | |
Scanner questionScanner = new Scanner(System.in); | |
String userAnswer = questionScanner.nextLine(); | |
System.out.println("userAnswer = " + userAnswer); | |
if (userAnswer.equals("1")) { | |
System.out.println("Deposit money"); | |
System.out.println("How Much?"); | |
String howMuchStr = questionScanner.nextLine(); | |
} | |
if (userAnswer.equals("2")) { | |
System.out.println("Withdraw"); } | |
if (userAnswer.equals("3")) { | |
System.out.println("Print Account Information"); } | |
if (userAnswer.equals("4")) { | |
System.out.println("Print Bank Information"); | |
if (userAnswer.equals("x")) { | |
System.out.println("Exit"); } | |
} | |
} | |
} | |
} | |
public static void test() { | |
System.out.println("This account is jsut for testings"); | |
BankAccount testBankAccount = new BankAccount(); | |
testBankAccount.printInfo(); | |
testBankAccount.deposit(10.00); | |
System.out.println(testBankAccount.getBalance()); | |
Bank testBank = new Bank(); | |
testBank.printInfo(); | |
testBank.addBankAccount(testBankAccount, 0); | |
testBank.printInfo(); | |
BankAccount anotherTestAccount = new BankAccount(); | |
anotherTestAccount.deposit(100.00); | |
testBank.addBankAccount(anotherTestAccount, 1); | |
testBank.printInfo(); | |
} | |
public static void openBank() throws Exception { | |
new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor(); | |
Scanner lineScanner = new Scanner(System.in); | |
System.out.println("May I have your name pleae"); | |
String userName = lineScanner.nextLine(); | |
System.out.println("I've located your account "+ userName); | |
System.out.println("Please enter your password"); | |
String passWord = lineScanner.nextLine(); | |
for (int counter = 0; counter < 2; counter++) { | |
System.out.println("=========================="); | |
System.out.println("Please Wait "); | |
System.out.println(" "); | |
System.out.println(" "); | |
System.out.println("=========================="); | |
Thread.sleep(1000); | |
clearScreen(); | |
System.out.println("============================"); | |
System.out.println("Retreving Account "); | |
System.out.println("Account "); | |
System.out.println("Information "); | |
System.out.println("============================"); | |
Thread.sleep(1000); | |
clearScreen(); | |
System.out.println("============================ "); | |
System.out.println(" "); | |
System.out.println("ONE MOMENT PLEASE "); | |
System.out.println(" "); | |
System.out.println("============================"); | |
Thread.sleep(1000); | |
clearScreen(); | |
System.out.println("============================="); | |
System.out.println("lOADING ACCOUNT INFORMATIONO "); | |
System.out.println(" "); | |
System.out.println(" "); | |
System.out.println("============================="); | |
Thread.sleep(1000); | |
clearScreen(); | |
} | |
System.out.println("****************************"); | |
System.out.println("PLEASE ENTER "); | |
System.out.println("THE LAST FOUR OF "); | |
System.out.println("SOCIAL SECURITY NUMBER "); | |
System.out.println(" "); | |
System.out.println("XXX -XXX-****"); | |
Scanner lineScannerPin = new Scanner(System.in); | |
String str =lineScannerPin.nextLine(); | |
int pinLength = str.length(); | |
String secretPin = ""; | |
for (int pinCount = 0; pinCount < pinLength; pinCount++) { | |
secretPin = secretPin + "*"; } | |
System.out.println(" SSN "+secretPin); | |
clearScreen(); | |
System.out.println("I've located two accounts press 1 for Busines Checking or 2 for Personal Savings"); | |
System.out.println(" you have 2 options "); | |
System.out.println(" *1* Busines Checking"); | |
System.out.println(" *2* Personal Savings"); | |
String userCommanChoice = lineScanner.nextLine(); | |
System.out.println("The user chose option" + userCommanChoice); | |
boolean userChoseOptionOne = userCommanChoice.equals("1"); | |
boolean userChoseOptionTwo = userCommanChoice.equals("2"); | |
if (userChoseOptionOne) { | |
businessChecking(); | |
} | |
if (userChoseOptionTwo) { | |
personalChecking(); | |
} | |
} | |
public static void clearScreen() throws Exception { | |
new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor(); | |
} | |
public static void businessChecking() { | |
Bank businessCheck = new Bank(); | |
BankAccount bC = new BankAccount(); | |
for (int counter = 0; counter < 100; counter++) { | |
System.out.println("Welcome to your BC account would like to "); | |
System.out.println(" 1 Make a deposit "); | |
System.out.println(" 2 Make a withdrawal "); | |
System.out.println(" 3 Print Account information "); | |
System.out.println(" 4 Print Bank information "); | |
System.out.println(" 5 Exit "); | |
Scanner lineScanner = new Scanner(System.in); | |
String userCommanChoice = lineScanner.nextLine(); | |
System.out.println("The user chose option" + userCommanChoice); | |
boolean userChoseOptionOne = userCommanChoice.equals("1"); | |
boolean userChoseOptionTwo = userCommanChoice.equals("2"); | |
boolean userChoseOptionThree = userCommanChoice.equals("3"); | |
boolean userChoseOptionFour = userCommanChoice.equals("4"); | |
boolean userChoseOptionFive = userCommanChoice.equals("5"); | |
if (userChoseOptionOne) { | |
System.out.println(" What amount wouold you like to deposit "); | |
String rawInput = lineScanner.nextLine(); | |
double userDepositAsADouble = Double.parseDouble(rawInput); | |
System.out.println("the amount of your deposit is " + rawInput); | |
bC.deposit(userDepositAsADouble); | |
} | |
if (userChoseOptionTwo) { | |
//System.out.println("What amount would you like to withdraw "); | |
String rawInput = lineScanner.nextLine(); | |
double userWithDrawAsADouble = Double.parseDouble(rawInput); | |
System.out.println(" the amount of your withdrawal is " + rawInput); | |
bC.withdraw(userWithDrawAsADouble); | |
} | |
if (userChoseOptionThree) { | |
System.out.println(" here is your Bank Information "); | |
bC.printInfo(); | |
} | |
if (userChoseOptionFour) { | |
System.out.println("here is your Bank Information"); | |
businessCheck.printInfo(); | |
bC.printInfo(); | |
} | |
if (userChoseOptionFive) { | |
System.out.println("Exit online"); | |
break; | |
} | |
} //4loop | |
} | |
public static void personalChecking() { | |
for (int counter = 0; counter < 4; counter++) { | |
System.out.println("Welcome to your BC account would like to "); | |
System.out.println(" 1 Make a deposit "); | |
System.out.println(" 2 Make a withdrawal "); | |
System.out.println(" 3 Print Account information "); | |
System.out.println(" 4 Print Bank information "); | |
System.out.println(" Exit "); | |
Scanner lineScanner = new Scanner(System.in); | |
String userCommanChoice = lineScanner.nextLine(); | |
System.out.println("The user chose option" + userCommanChoice); | |
} //4loop | |
} | |
public static void main(String[] args) throws Exception { | |
System.out.println("Welcome to Bank of Atlanta"); | |
System.out.println ("Which Bank Account would you like to access today you have to options or your can open a new account"); | |
System.out.println("Options 1 Bank of America"); | |
//System.out.println("Options 2 Ghetto Brand Banking"); | |
System.out.println("Options 3 Open new account"); | |
Scanner lineScanner = new Scanner(System.in); | |
String userCommanChoice = lineScanner.nextLine(); | |
System.out.println("The user chose option " + userCommanChoice); | |
boolean userChoseOptionOne = userCommanChoice.equals("1"); | |
boolean userChoseOptionTwo = userCommanChoice.equals("2"); | |
boolean userChoseOptionThree = userCommanChoice.equals("3"); | |
if (userChoseOptionOne) { | |
openBank(); | |
} | |
if (userChoseOptionTwo) { | |
test(); | |
} | |
if (userChoseOptionThree) { | |
getUserInputInloop(); | |
askUserQuestions(); | |
} | |
} | |
} | |
//System.out.println("amount u have is"); | |
//String totalMoneyAtTheBank = lineScanner.nextLine(); may use for options 3 | |
//System.out.println("here is your accoount information " + totalMoneyAtTheBank); | |
//businessCheck.printInfo(totalMoneyAtTheBank); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment