Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Objective: Understand and demonstrate writing classes instantiate objects of these classes test my class by invoking methods in a demo class Students will write 3
Objective:
Understand and demonstrate writing classes
instantiate objects of these classes
test my class by invoking methods in a demo class
Students will write classes: BankAccount.java, BankAcountDemo.java and Financial.java
the BankAccount.java class should have the following components:
instance variables : balancedouble accNameString accNumint accountTypechar interestRatedouble default
static variable : lastAccNum this should be an int
constructors : default and an overloaded constructor that takes in explicit parametersbalance accName, and accountType to initialize the fields. demonstrate the use of
the keyword "this" The other two fields accNum and interestRate will be assigned values inside the constructor. The accNum is based on the static variable lastAccNum. This
static var should be incremented in the constructors and then assigned to the accNum.
methods: All methods must be professionally documented using Javadocs, @param@return@exception
setter methods : setBalance, setName, setAccountType, and setInterestRate
getter methods : getBalance, getName, getAccountType, and getInterestRate
a withdraw method
a deposit method
a transfer method: transfers money from one account to another by passing in a bank account object and an amount.
a displayAccountInfo method
an addInterest method that invokes the static method percentOf from the Financial class and takes in two parameters; the interestRate field and the balance field. In this method
interest will be added only to savings accounts according to the interestRate value. You should NOT add interest to a checking account.
Note: after calculating the interest, you will need to add it to the balance.
The BankAccountDemo.java class should have the following:
Create objects AdamsAcc C SamsAccS and LeilasAccS use the default constructor for the first object and the second constructor for second and third object.
you are free to test your code and use the methods on any objects, but make sure to:
adam should be a checking acc. and Leila and Sam should be a saving acc.
invoke and demonstrate all the methods write comments in your demo class stating which methods are being tested.
Invoke the addlnterest method two times; once with LeilasAcc and once with SamsAcc.
invoke the displayAccountInfo method several times to show all the changes.
Final Step:
add an IllegalArgumentException where applicable withdraw methodtransfer whenever the amount to be withdrawn exceeds the balance.
Test this by trying to withdraw or transfer an amount that is greater then the balance in your Demo class.
Take a snapshot of the the generated exception.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started