Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You must write tests for the following: It should have 3 exception classes; AccountIDFormatException,DepositLimitException,NegativeBalanceException You must write tests for the following (which may include Custom

You must write tests for the following:

It should have 3 exception classes; AccountIDFormatException,DepositLimitException,NegativeBalanceException

You must write tests for the following (which may include Custom Exceptions):

  • BankAccount1 Class
    • Tests are written such that any deposit that is made greater than 10000 is not accepted.

    • Tests are written such that balance in the BankAccount1 does not go below 0.

    • Care should be taken for above tests at the time of Initial Deposit and at the time of Withdrawal and future Deposits.

    • Make corresponding changes in methods of BankAccount1 class to invoke exceptions.

CODE: BankAccount1.java

public class BankAccount1 { private String accountID; private double balance;

/** Constructs a bank account with a zero balance @param accountID - ID of the Account */ public BankAccount1(String accountID) { balance = 0; this.accountID = accountID; }

/** Constructs a bank account with a given balance @param initialBalance the initial balance @param accountID - ID of the Account */ public BankAccount1(double initialBalance, String accountID) {

this.accountID = accountID; balance = initialBalance; } /** * Returns the Account ID * @return the accountID */ public String getAccountID() { return accountID; } /** * Sets the Account ID * @param accountID */ public void setAccountID(String accountID) { this.accountID = accountID; }

/** Deposits money into the bank account. @param amount the amount to deposit */ public void deposit(double amount) {

balance += amount; }

/** Withdraws money from the bank account. @param amount the amount to withdraw @return true if allowed to withdraw */ public boolean withdraw(double amount) { boolean isAllowed = balance >= amount; if (isAllowed) balance -= amount; return isAllowed; }

/** Gets the current balance of the bank account. @return the current balance */ public double getBalance() { return balance; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

Students also viewed these Databases questions

Question

=+6 Who is the peer of the IA ?

Answered: 1 week ago

Question

=+herself to in terms of equity with regard to this assignment?

Answered: 1 week ago