public static void main(String[] args) {

    Account momsSavings = new Account(1000);
    momsSavings.addInterest(10);

    System.out.println("The balance in momsSavings is $" + momsSavings.getBalance());
  }
 /*
  * Adds earned interest to the account
  *
  * @param t A reference to some arbitrary Transaction object
  * @param account A reference to an Account object to which the earned interest is added
  * @param transactionType The type of transaction (eg deposit, withdrawal)
  * @param amount The amount processed during the transaction
  * @param date The date of the transaction in the form mmddyyyy
  * @param fees A description of any unusual fees
  */
 public void makeInterestDeposit(
     Transaction t,
     Account account,
     String transactionType,
     double amount,
     String date,
     String fees) {
   double earnedInterest = account.getBalance() * account.getCustomer().getSavingsInterest() / 100;
   account.addInterest();
   makeTransaction(t, account, transactionType, earnedInterest, date, fees);
 }
예제 #3
0
  // -----------------------------------------------------------------
  //  Creates some bank accounts and requests various services.
  // -----------------------------------------------------------------
  public static void main(String[] args) {
    Account acct1 = new Account("Ted Murphy", 72354, 25.59);
    Account acct2 = new Account("Angelica Adams", 69713, 500.00);
    Account acct3 = new Account("Edward Demsey", 93757, 769.32);

    acct1.deposit(44.10); // return value ignored

    double adamsBalance = acct2.deposit(75.25);
    System.out.println("Adams balance after deposit: " + adamsBalance);

    System.out.println("Adams balance after withdrawal: " + acct2.withdraw(480, 1.50));

    acct3.withdraw(-100.00, 1.50); // invalid transaction

    acct1.addInterest();
    acct2.addInterest();
    acct3.addInterest();

    System.out.println();
    System.out.println(acct1);
    System.out.println(acct2);
    System.out.println(acct3);
  }
예제 #4
0
 /*public void addInterest_all_accounts(){
     Account account;
     for (int x=0; x<accountslist.size(); x++){
        account=(Account)accountslist.get(x);
        account.addInterest(); // POLYMORPHISM HERE!!
     }
 }*/
 public void addInterest_all_accounts() {
   Account account;
   for (Account acct : accountslist) {
     acct.addInterest(); // POLYMORPHISM HERE!!
   }
 }