Question: Problem 4 - A simple banking system (25 points) In this problem you are going to create a simple model of a banking system based

Problem 4 - A simple banking system (25 points) In this problem you are going to create a simple model of a banking system based on inheritance and polymorphism, according to the specifications in the given UML diagram. Besides the three classes given in the diagram, you are going to create also a BankManager class which will provide three static methods:

printOverAllInfo method which receive as input a polymorphic array of bank accounts and will print the information about all accounts specifying the account type, id, balance and other additional attributes if applicable. rewardAll method which receive as input a polymorphic array of bank accounts and will deposit a reward on all account according to the following policy: o each saving account will be rewarded 50 dollars o each checking account will be rewarded 75 dollars o each general account will be rewarded 25 dollars depositAllYearlyInterests method which will receive as input a polymorphic array of bank accounts and will deposit the yearly interest to all saving accounts (no operations will be done on accounts which are not saving accounts). public class BankManager { public static void printOverallInfo(BankAccount[] accounts){ //to do } public static void rewardAll(BankAccount[] accounts){ //to do } public static void depositAllYearlyInterests(BankAccount[] accounts){ //to do } }

As a tester class you may use the following one: public class Tester { public static void main(String[] args) { BankAccount[] accounts = new BankAccount[6]; accounts[0] = new SavingsAccount("D4051", 6503.5, 0.02); accounts[1] = new BankAccount("G7725", 10875.0); accounts[2] = new SavingsAccount("K1605", 15794.5, 0.03); accounts[3] = new CheckingAccount("E5964", 9624.75); accounts[4] = new CheckingAccount("F8723", 3455.5); accounts[5] = new SavingsAccount("L8219", 24050.25, 0.025); System.out.println("The overall info of the accounts initially:"); BankManager.printOverallInfo(accounts); System.out.println(" Rewarding all the accounts..."); BankManager.rewardAll(accounts); //no output is printed System.out.println(" Depositing the interest to all saving accounts ..."); BankManager.depositAllYearlyInterests(accounts); //no output System.out.println(" The overall info of the accounts at the end of operations:"); BankManager.printOverallInfo(accounts); } }

Problem 5 - Your example about inheritance and polymorphism (20 points) In this problem you are going to create a simple example using inheritance and polymorphism (similar to the example of the previous question). Describe carefully the scenario of your example and provide the complete implementation (all the classes related to the scenario and also a tester class).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!