Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BankingDriver { //The name of the class
- public static void main (String [] args){ //First thing the pc looks at
- Banking nicksAcct = new Banking("Nick", 450, 500); //Creates the nicksAcct Object
- Banking carolsAcct = new Banking("Carol", 600, 700); //Creates the carolsAcct Object
- System.out.println(nicksAcct.getTotalMoney() + carolsAcct.getTotalMoney()); //Adds both of the accounts together and prints them on 1 line
- nicksAcct.setCheckMoney(nicksAcct.getCheckMoney + 100); //Calls for the total amount in Nicks Checking and adds on 100 dollars
- System.out.println(nicksAcct); //Prints nicks account
- Banking tempMoney = new Banking ("Temp", 0, 0); //Creates an intermediate variable
- tempMoney.setCheckMoney(nicksAcct.getCheckmoney + nicksAcct.getSaveMoney); //Moves all of the money from nick to temp check account
- nicksAcct.setCheckMoney(0); //sets nicks check money to 0
- nicksAcct.setSaveMoney(0); //sets nicks save money to 0
- carolsAcct.setSaveMoney(tempMoney.getCheckMoney + carolsAcct.getSaveMoney); //moves all the money to carols existing saving acount
- tempMoney.setCheckMoney(0); //sets check money to 0
- System.out.println(nicksAcct.getTotalMoney()); //prints out nicks account information
- System.out.println(carolsAcct.getTotalMoney()); //prints out carols account information
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement