Class file for BankAccount Java Topic: Creating your own classes in Java. Requirements: Create a class called BankAccount that has Two instance variables
Class file for BankAccount Java Topic: Creating your own classes in Java.
Requirements:
Create a class called BankAccount that has
Two instance variables: balance of type double and accountNumber of type String.
Accessor (getter) Methods:
getBalance() which returns the value of the instance variable balance.
getAccountNumber() which returns the value in the instance variable accountNumber.
toString() which returns the information in the instance variables in the following format:
Mutator (setter) Methods:
deposit and withdraw. Each take a double as an argument and don’t return anything.
Constructors:
Default (no arguments)
One that takes a start balance.
One that takes a start balance and account number.
All methods should ensure that the balance in a bank account is never overdrafted (a negative amount) and that only positive amounts are deposited/withdrawn.
Use JUnit Test to test the code. (When it’s run, it should say that there are no errors/failures)
Create a new folder.
Put junit-4.12.jar and hamcrest-core-1.3.jar in this folder (available below).
Copy the test code with possible supporting files in this same folder.
Create the file with code as required.
Compile your code and the test code using the command javac -cp .;junit-4.12.jar:hamcrest-core-1.3.jar *.java
Run the test using the command java -cp .;junit-4.12.jar:hamcrest-core-1.3.jar org.junit.runner.JUnitCore BankAccountIA2Test
Take a screenshot of cmd to show that file is working properly. If you need more information leave a question and I’ll try to answer them ASAP. Thank you.