bank - import import import import import java.io.File;

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class Bank implements Cloneable { private Account[] accounts; public Bank(Account[] accounts) { this.accounts = accounts; } // sort by compareTo public void sortByBalance() { Arrays.sort(accounts); } // sort by compare public void sortByOwner(Account a) { Arrays.sort(accounts, a); } public void modifyAccountBalance(int i, double balance) { if (i > accounts.length) return; if (accounts[i] == null) return; accounts[i].setBalance(balance); } // clone public Object clone() { Account acc2 = new Account[acounts.length]; for(int i = 0; i<acc2.length; i++) { if(account[i] instanceof CheckingAccount) acc2[i]=(CheckingAccount) ((CheckingAccount)account[i]).clone(); if(account[i] instanceof InterestAccount) acc2[i]=(InterestAccount) ((InterestAccount)account[i]).clone(); } Bank bank = new Bank(acc2); return bank; } // writes to file public void writeToFile(String outputFile)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

bank - import import import import import java.io.File;

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online