Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package test;
- import java.util.*;
- public class exec{
- /*
- * The bank is created.
- * They set up their database ready for adding accounts.
- * It is totally empty.
- * They are hoping to get rich off interest rates,
- * taking money from people just for having lots of it to lend.
- */
- static ArrayList<BankAccount> accounts = new ArrayList<BankAccount>();
- static int accountNumberSearch(String accNumGiven){
- for(int i = 0; i < accounts.size(); i++){
- if(accounts.get(i).getAccountNumber() == accNumGiven){
- return i; //finds the index of an account using the account number
- }
- }
- return -1; //This means the account was not found
- }
- static int nameSearch(String nameGiven){
- for(int i = 0; i < accounts.size(); i++){
- if(accounts.get(i).getName() == nameGiven){
- return i; //finds the index of an account using the name
- }
- }
- return -1; //This means the account was not found
- }
- public static void main(String [] args){
- System.out.println("Transaction logs\n--------------------------------------------------------------------------");
- /*
- * The bank is sees it's first victim, a fool to swindle.
- * He walks up to the teller. Her name is Gertrude.
- * She owns a friendly neighborhood drugstore.
- * (She wants to expand her business, by getting a loan
- * to buy a space to set up shop in more places)
- *
- * But right now, she wants to make a simple savings account.
- *
- * The bank teller replies, "OF COURSE! WE'D LOVE TO TAKE YOUR MONEY!"
- *
- * Gertrude hands her money over and also gives personal information,
- * now the bank teller knows where Gertude lives.
- *
- * The teller makes her an account, since her account is number 1,
- * it'll be 15L0000001, since this is the 15th branch to use the database
- * system to make accounts.
- *
- * Gertrude hands over the money (1000$), what a sucker!
- *
- */
- // new BankAccount(" FULLNAME ", "ACCOUNTID", " ADDRESS ", " CITY ", "STATE", "ZIPCODE", "BALANCE");
- accounts.add(new BankAccount("15L0000001", "Gertrude Kingston", "1232 NW 329 Ave", "Hialeah", "FL" , "32102" , 1000));
- /*
- * Would you look at that... after Gertrude left, another poor sap called
- * Antwon came in and made an account of his own, these bankers are real
- * scumbags, I tell you.
- *
- * But thats not the end of it! His little brother, Sean, also made an account!
- *
- */
- accounts.add(new BankAccount("15L0000002", "Antwon Tyrell", "11 NW 227 Ave", "Miami", "FL" , "33175" , 500));
- accounts.add(new BankAccount("15L0000003", "Sean Tyrell", "11 NW 227 Ave", "Miami", "FL" , "33175" , 300));
- /*
- * Days later, Gertrude comes back to the bank. She still hasn't decided to get
- * a loan of cash, but she wants to put in EVEN MORE money! She's been brainwashed!
- *
- * The bank teller asks her for her account number. She says "16O0000011 or something."
- *
- * The teller is not amused, and resorts to looking up her account by her name.
- *
- */
- if(nameSearch("Gertrude Kingston") != -1){
- System.out.println("Your account number is " + accounts.get(nameSearch("Gertrude Kingston")).getAccountNumber() + "."); //says the teller in a sarcastic voice.
- //the teller doesn't even ask for identification!
- //"Money? Sure, we don't care! Cough it up!", thinks the teller.
- if(accounts.get(nameSearch("Gertrude Kingston")).deposit(200)){// I'm aware this is redundant
- System.out.println("Your balance is now $" + accounts.get(nameSearch("Gertrude Kingston")).getBalance() + ". Thank you for your services, "+accounts.get(nameSearch("Gertrude Kingston")).getName()+".");
- }else{
- //If this case were to happen, it'd be because the amount deposited is negative.
- }
- } else {
- System.out.println("It appears there is nobody with that name is registered in this bank. Would you like to make an account?");
- }
- /*
- * Meanwhile, Antwon spends a couple bucks to buy himself a new iPhone.
- * He uses his debit card, and the money is withdrawn from his account
- * and is then transferred to the store by another intermediary service
- * using his account number.
- *
- * But forget the banks for a second, he just wasted $800 on a PHONE!
- * He could've just ordered an android phone online for around $300 instead!
- *
- * And lets not forget... he deposited only $500! He doesn't have enough!
- *
- */
- if(accounts.get(accountNumberSearch("15L0000002")).withdraw(800)){
- System.out.println("TRANSACTION FROM ACCOUNT 15L0000002 APPROVED.");
- //This won't happen since he doesn't have enough
- }else{
- System.out.println("TRANSACTION FROM ACCOUNT 15L0000002 DENIED: Insufficient funds.");
- }
- /*
- * Well, this is really Antwon's fault. He didn't have enough. Luckily, his bank didn't overdraft him.
- * Maybe now he'll get an android phone.
- *
- * As for his brother Sean, he just got in a car accident and bumped his head, and he doesn't remember
- * anything. He runs over to a bank and tells them what happened, and how he needs to withdraw cash to
- * pay for the tow and a cab home, wherever his home is. The bank teller then points out that he should
- * have his identification with him at all times, and is required for withdrawals.
- *
- * A thought! His ID! Salvation! He sees his name laminated on it is... Sean Tyrell? Sounds like a name some
- * kid writing a program about banks came up with off the top of his head. He provides the info and asks what
- * his balance is, and that is, if he even has a bank account.
- *
- */
- if(nameSearch("Sean Tyrell") != -1){
- System.out.println("Your balance is $" + accounts.get(nameSearch("Sean Tyrell")).getBalance() + ", Sean Tyrell.");
- }
- /*
- * Sean was hoping he was rich, but disappointment fills him. He decides to withdrawal all of it,
- * his entire balance.
- *
- */
- if(accounts.get(nameSearch("Sean Tyrell")).withdraw(accounts.get(nameSearch("Sean Tyrell")).getBalance())){
- System.out.println("Your balance is now $" + accounts.get(nameSearch("Sean Tyrell")).getBalance() + ".");
- }else{
- //something would have gone wrong if this were to happen.
- }
- }
- }
Add Comment
Please, Sign In to add comment