Integration Test Exercise in JAVA

0

Test or Integration Test Consider the following Bank class:

public class Bank{private Account[] accounts;

    public Bank(int numAccounts) {
        accounts = new Account[numAccounts];
    }

    public int getNumberAccounts() {
        int i = 0;
        while (accounts[i]!=null)
            i++;
        return i;
    }

    public void createAccount(Account account) {
        accounts[getNumberAccounts()] = account;
    }

    public void displayAccounts() {
        for (int i = 0; i < getNumberAccounts(); i++) {
            System.out.print("Account [" + i + "]: holder name is " + accounts[i].getHolder());
            System.out.println(" and balance is " + accounts[i].getBalance());
        }
    }
}    

Test the integration between the Account and Bank classes by implementing the BankTest class. In the main method, you must create a bank and then an account in that bank. The holder name of the account is John and his initial balance equals $ 500; Afterwards, it shows the accounts created in the output. Which lines will create the test correctly? Note: The order of the line is indicated in brackets. (Select all the correct options)

Bank bank = new Bank(50); {línea 1}

bank.createAccount(account); {línea 1}

Account account = new Account("John", 500); {línea 2}

Bank bank = new Bank(); {line 2}

Account account = new Account(500, "John"); {línea 3}

bank.createAccount(account); {línea 3}

bank.displayAccounts(); {línea 4}

account.displayAccounts(); {línea 4}
    
asked by Majunia 28.12.2018 в 20:38
source

0 answers