output should look like this Class design User Class design

output should look like this:

Class design: User

Class design: account

class design: accountlist

Class Design: AccountList The AccountList class is intended to be an abstract and simplified representation of a list of accounts. Class Properties Accounts (an array of Account objects-or ArrayList) · o No getters or setters* (do you know why?) Class Invariant » Can\'t have multiple accounts with the same username Class Components A public method that adds new accounts · A public (boolean) method that determi A public (boolean) method that determines whether an account with a given username exists in . the list Grading Criteria » User class object o [2 points] Implements all required properties o o o - [2 points] Implements appropriate getters/setters [2 points] All invariants properly enforced [2 points] Required class components properly implemented [2 points] Driver class requirements are met » Account class object o [2 points] Implements all required properties [1 point] Implements appropriate getters - o o o [2 points] All invariants properly enforced [2 points] Required class components properly implemented [2 points] Driver class requirements are met » AccountList class object o o o o [2 points] Implements all required properties [2 points] All invariants properly enforced [2 points] Required class components properly implemented [2 points] Driver class requirements are met . [1 point] Method Java Doc: description, @param, @return » [1 Point] Descriptive variable names » [1 Point] Appropriate class header comment block

Solution

Please find below the java program named AccountList.java:


import java.io.PrintWriter ;
import java.io.IOException ;
import java.util.ArrayList ;

/**
The bank contains a list of bank accounts.
*/
public class Bank
{   
private ArrayList<BankAccount> accounts ; // a list of BankAccount objects

/**
Here we Constructs a bank which got no bank accounts.
*/
public Bank()
{
accounts = new ArrayList<BankAccount>() ;
}

/**
To Add an Account to the Bank
@param a the account to add
*/
public void addAccount(BankAccount a)
{
accounts.add(a) ;       // calls \"add\" method of ArrayList class
}

/**
Here we Print data for all the accounts into the screen and also to an output file
*/
public void printList() throws IOException
{
// create output file in default folder
PrintWriter toFile = new PrintWriter(\"BankAccounts.out\") ;
  
// print headings to screen
System.out.printf(\"%15s%20s%n\",\"Account Number\",\"Account Balance\") ;
  
System.out.printf(\"%15s%20s%n\",\"==============\",\"===============\") ;

// print headings to file
toFile.printf(\"%15s%20s%n\",\"Account Number\",\"Account Balance\") ;
  
toFile.printf(\"%15s%20s%n\",\"==============\",\"===============\") ;

// for each of the account belonging to this bank
for ( int i = 0 ; i < accounts.size() ; i++ )
{
BankAccount active = accounts.get( i ) ;   // To receive next account

// This will print the account number and the bal. into the screen
System.out.printf(\"%15s $%14.2f%n\",active.getAccountNumber(),
active.getBalance()) ;

// This will print the account number and the bal. into a file
toFile.printf(\"%15s $%14.2f%n\",active.getAccountNumber(),
active.getBalance()) ;
}
  
toFile.close() ;   // always remember to close file!
}


public double getTotalBalance()
{
double total = 0;
  
// for each account in this bank
for ( int index = 0 ; index < accounts.size() ; index++)
{
BankAccount active = accounts.get(index) ;   
total = total + active.getBalance() ;
}
return total ;
}

  
public int count(double atLeast)
{
int matches = 0 ;
for ( int i = 0 ; i < accounts.size() ; i++ )
{
BankAccount active = accounts.get( i ) ; // To get the account
if (active.getBalance() >= atLeast)    // found one...
matches++ ; // ...increment counter
}
return matches ;
}


public BankAccount find(String acctNum)
{
for ( int i = 0 ; i < accounts.size() ; i++ )
{
BankAccount active = accounts.get( i ) ; // To get the account
   String accountNum = active.getAccountNumber()   ; // To get account number
   if ( accountNum.equals(acctNum) )        
return active ;          
}
return null ; // There is No match in the entire array list
}


public BankAccount getMaximum()
{
if (accounts.size() == 0)        // if no accounts, return null
return null;
  
// Here just assume the first account is the largest
BankAccount largestYet = accounts.get(0) ;
  
// for all other accounts
for ( int i = 1; i < accounts.size(); i++ )
{
BankAccount active = accounts.get(i) ;       // To get next account
// is active account > highest so far?
if (active.getBalance() > largestYet.getBalance())
largestYet = active ;
}
return largestYet ;
}
}

output should look like this: Class design: User Class design: account class design: accountlist Class Design: AccountList The AccountList class is intended to
output should look like this: Class design: User Class design: account class design: accountlist Class Design: AccountList The AccountList class is intended to
output should look like this: Class design: User Class design: account class design: accountlist Class Design: AccountList The AccountList class is intended to

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site