Answered step by step
Verified Expert Solution
Question
1 Approved Answer
me understand this homework Objective: Understand and demonstrate writing classes instantiate objects of these classes test my class by invoking methods in a demo class
me understand this homework 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 classes: BankAccount.java, BankAcountDemo.java and Financial.java the BankAccount.java class should have the following components: 5 instance variables : balance(double), accName(String), accNum(int), accountType(char), interestRate(double) default 3 % 1 static variable : lastAccNum = 0 (this should be an int) 2 constructors : default and an overloaded constructor that takes in 3 explicit parameters(balance, 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. 13 methods: (All methods must be professionally documented using Javadocs, @param/@return/@exception) 4 setter methods : setBalance, setName, setAccountType, and setInterestRate 4 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 3 objects AdamsAcc (C), SamsAcc(S), and LeilasAcc(S) 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 addInterest 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 method/transfer) 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