Question: java thank you! 3 files seprate! 1.Bank.java 2.BankAccount.java (provided) 3.BankTester.java(provided) Use the following files: BankAccount.java /** A bank account has a balance that can be

java thank you!

3 files seprate!

1.Bank.java

2.BankAccount.java (provided)

3.BankTester.java(provided)

java thank you! 3 files seprate! 1.Bank.java 2.BankAccount.java (provided) 3.BankTester.java(provided) Use the

Use the following files:

BankAccount.java

/** A bank account has a balance that can be changed by deposits and withdrawals. */ public class BankAccount { private double balance; private String accountId; /** Constructs a bank account with a given balance. @param initialBalance the initial balance @param id the id for this account */ public BankAccount(double initialBalance, String id) { balance = initialBalance; accountId = id; } /** * Gets the id for this account * @returns the id for this account */ public String getAccountId() { return accountId; } /** Deposits money into the bank account. @param amount the amount to deposit */ public void deposit(double amount) { balance = balance + amount; } /** Withdraws money from the bank account. @param amount the amount to withdraw */ public void withdraw(double amount) { balance = balance - amount; } /** Gets the current balance of the bank account. @return the current balance */ public double getBalance() { return balance; } } 

BankTester.java

public class BankTester { public static void main(String[] args) { Bank accounts = new Bank(); //test empty bank accounts.largestFirst(); System.out.println(accounts.list()); System.out.println("Expected: []"); accounts.largestFirst(); System.out.println(accounts.list()); System.out.println("Expected: []"); System.out.println(accounts.contains("abc123")); System.out.println("Expected: false"); System.out.println(accounts.list(10000)); System.out.println("Expected: []"); accounts.add(new BankAccount(10000.0, "def333")); accounts.add(new BankAccount(20000.0, "abc123")); accounts.add(new BankAccount(15000.0, "pqr456")); accounts.add(new BankAccount(20000.0, "xyz789")); accounts.add(new BankAccount(9500.0, "abc111")); accounts.largestFirst(); System.out.println(accounts.list()); System.out.println("Expected: [abc123, def333, pqr456, xyz789, abc111]"); System.out.println(accounts.contains("abc123")); System.out.println("Expected: true"); System.out.println(accounts.contains("aaa999")); System.out.println("Expected: false"); System.out.println(accounts.list(10000)); System.out.println("Expected: [abc123, pqr456, xyz789]"); System.out.println(accounts.list(100000)); System.out.println("Expected: []"); // accounts.add(); } }

In this problerm you will implement a solution using the design pattern for collecting objects. We are going to model a bank. A Bank uses an ArrayList to keep track of BankAccount objects. You will write the Bank class The BankAccount class is provided for you. A BankAcount has a balance and a accountld. A Bank has a constructor that takes no parameters. It needs to initialize the ArrayList used to collect bankAccounts It has methods add adds the specified BankAccount to the Bank largestFirst puts the BankAccount with the largest balance first in the list. If two have the same large balance, use the first one encountered in the list . contains determines if a BankAccount with a i ist gets an ArrayList of the BankAccount account!ds in the Bank that have balances over the specified amount. given accountld is in the Bank. Return true is so, otherwise false list gets an ArrayList of the BankAccount accountlds in the Bank Provide Javadoc

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!