Financial Account Manager You are part of a company that hasacquired (bought) the producer of the Ba

Financial Account Manager You are part of a company that hasacquired (bought) the producer of the Banking Account Managersoftware. Your company wants to greatly improve this software so itcan handle all types of accounts and investments. Among theseaccount types are: • Savings Accounts – (class SavingsAccount) An account thatholds money but is limited to deposits and withdrawals • Mutual Funds – (class MutualFundAccount) An investment accountcomprised of a collection of stock in various companies. The fundis tracked simply in terms of an overall share price (notindividual company’s share prices). • Stocks – (class StockAccount) This account type tracks acollection of different stocks and the number of shares of eachowned by the individual. The CheckingAccount class should be modified to add a membernamed ‘suffix’. All the new account classes you will create need a‘suffix’ to distinguish them. The ‘suffix’ will be a 2 characterstring as follows: • Checking: ‘70’ • Savings: ‘73’ • MutualFund: ‘MF’ • Stock:‘SA’ The ‘suffix’ does NOT need to be passed into the constructor.Each class knows what it is and can fill in the field whenever itprints information about the account (i.e. in the toString() methodyou will implement). New Classes Here are details on the new classes needed for the accountmanager. Savings Accounts Savings accounts holds a balance. Theyare created in the same way as checking accounts (so theconstructor takes the same arguments.) These accounts track abalance based on the initial balance with adjustments for eachtransaction. These accounts accept only the following transaction types: • Deposit – Deposit money into the account • Withdrawal –Withdraw money from the account • Interest – Periodic Interestadded to account Mutual Funds Mutual Funds are comprised of a collection of stocks fromdifferent companies. The collection of stock values are combinedinto a single value per ‘share’ of the money market. So this simplytracks the number of shares and the price per share. The number ofshare can have a fractional part so this should be declared as adouble! Shares may change in value. This means the value of themutual fund holding may go up or down (since the shares do notchange unless more are purchased or some are sold). The valid transactions for a mutual fund are: • buyMF – This purchases shares. The call must provide a dollaramount to use for the purchase. The funds come from a savings orchecking account so those must be updated by sending a withdrawaltransaction to the account. The number of shares purchased is thedollar amount divided by the current share price. That share amountshould be added to the current share count. • sellMF – Sells anumber of shares. This number is a double so you can sellfractional amounts of shares. The proceeds (shares to sell x priceper share), is placed into a designated account which must be oftype Checking or Savings. • updateMFSharePrice – This simplychanges the current price per share. Stocks A stock account tracks holdings for a list of different companystocks. The transactions supported are: • buyStock – Purchase shares. This requires indicating the stocksymbol and a number of shares to buy. The price per share must belooked up using the method getPriceBySymbol(String symbol) which ispart of a StockExchange object that is provided. The money topurchase the shares comes from one of the savings accounts(indicated in the transaction). • sellStock – Sell shares. Thisrequires indicating the stock symbol and a number of shares tosell. The price per share of the stock is acquired with thegetPriceBySymbol(String symbol) method. The proceeds from sellingthe shares are deposited into a specified account of type Savingsor Checking. Original Classes CheckingAccount you should have a CheckingAccount class which may need to bemodified slightly. The transactions it should support are: • Deposit – Deposit money into the account • Withdrawal – Withdraw money from the account • Interest – Periodic Interest added to account • CheckCashed – A check was cashed and paid out so this deductsthe amount from the account balance • PointOfSale – This is a purchase made with a debit card at avendor. So the amount is deducted from the balance. Transactions Transactions are now more varied than in the earlier design.This will require designing at least 2 new Transaction classes. Thecurrent Transaction class should be changed to an abstract class.In this way, it provides some basic functionality but cannot beinstantiated by mistake. Create 2 subclasses of this. The first iscalled SavingsTransactions and applies to Checking or Savingsaccounts. The second subclass is called InvestmentTransaction. Itis a parent class to the classes MutualFundTransaction used forMutualFund transactions and StockInvestmentTransaction used forStock account transactions. Transaction is an abstract class meaning it is not complete. Itrequires one method to be overridden. The method is selfCheck().This method checks the transaction for consistency (i.e. anInvestmentTransaction must be limited to certain types (buyStock,buyMF, etc.) SavingsTransactions should check that the amount isnot less than 0 and that the transaction types are permitted bysavings accounts. Here is the class hierarchy: Transaction(abstract) SavingTransaction InvestmentTransaction StockInvestmentTransaction MutualFundTransaction The test code will create different transactions of the abovementioned types to be applied to different accounts with theaddTransaction() method. For Stock sales and purchases, the cost per share must be lookedup with the method mentioned above. There should be a member inInvestmentTransaction that holds the price per share that isretrieved when the transaction is added. So the addTransactionroutine in the investment accounts must look up this price, verifythat funds are available for the purchase (if it is a ‘buy’transaction), add the price per share to the Transaction and thenstore the modified Transaction into the array of Transactions inthe account. StockInvestmentTransaction StockInvestmentTransaction inherits from InvestmentTransaction.This object must contain a member that is a StockHolding objectwhich contains the symbol and number of shares to be bought orsold. It also needs a member that is a double to hold the value pershare at the time of purchase. The Constructor for this class has the following prototype: public StockInvestmentTransaction(String date, intaccountNumber, TransactionType transType, StockHolding item,Savings sourceAccount); The sourceAccount parameter is a Savings or Checking accountwhere the funds will come from (on a purchase) or go to (on asale). This account object is held in InvestmentTransaction (seethe provided code.) MutualFundTransaction This is a transaction used for mutual fund purchases and sales.It will extend InvestmentTransaction and should have a member oftype double called amount that holds either a dollar amount ofshares to buy or a number of shares to sell. This will depend onthe type of transaction it holds (buyMF or sellMF). The constructorfor MutualFundTransaction has a prototype as follows: public MutualFundTransaction(String date, int accountNumber,TransactionType transType, double amount, SavingssourceAccount); The sourceAccount parameter is a Savings or Checking accountwhere the funds will come from (on a purchase) or go to (on asale). This account object is held in InvestmentTransaction (seethe provided code.) Interfaces Here are the various public methods that must be provided tooutside callers: CheckingAccount: public double getBalance(); This prints the balance in the checking account. public boolean addTransaction(Transaction trans); This adds a transaction. The method verifies that thetransaction type is allowed by this account type. It verifiesamount is greater than or equal to 0. If the validation checkswork, it should be added to the Transaction array. The methodreturns true if the transaction is accepted, false if it isrejected. public String toString(); This method formats and returns a string containing keyinformation. It should print the account number and suffix,separated by a ‘-‘. Then print the balance in the account in theformat to show US Dollars and cents (i.e. $12345678.99 – no ‘,’separators are needed but decimal should be 2 digits.) SavingsAccount: public double getBalance(); This prints the balance in the checking account. public boolean addTransaction(Transaction trans); This adds a transaction. The method verifies that thetransaction type is allowed by this account type. It verifiesamount is greater than or equal to 0. If the validation checkswork, it should be added to the Transaction array. The methodreturns true if the transaction is accepted, false if it isrejected. public String toString(); This method formats and returns a string containing keyinformation. It should print the account number and suffix,separated by a ‘-‘. Then print the balance in the account in theformat to show US Dollars and cents (i.e. $12345678.99 – no ‘,’separators are needed but decimal should be 2 digits.) MutualFundAccount: public double getValue(); This function computes the current value of the account based onthe amount of shares and the current price per share. It returnsthe computed value. public boolean addTransaction(Transaction trans); This adds a transaction. The method verifies that thetransaction type is allowed by this account type. If the type is tobuy mutual funds, it confirms that the sourceAccount in thetransaction has sufficient funds to cover the purchase. If not, thetransaction is rejected. If the validation checks work, thetransaction is added to the Transaction array. The method returnstrue if the transaction is accepted, false if it is rejected. public String toString(); This method formats and returns a string containing keyinformation. It should print the account number and suffix,separated by a ‘-‘. Then print the number of Mutual Fund sharesowned and the current value based on the current price per share.The value is formatted to show US Dollars and cents (i.e.$12345678.99 – no ‘,’ separators are needed but decimal should be 2digits.) StockAccount: public double getValue(); This function computes the current value of the account. This iscomputed by looking at each StockHolding record. For each record,multiply the shares of that company’s stock by the price per share.Sum the values for each company’s stock. This total value is thevalue to report. public StockHolding[] getHoldings(); This returns an array with each of the StockHolding recordscurrent held by the account. public booleanaddTransaction(Transaction trans); This adds a transaction. The method verifies that thetransaction type is allowed by this account type. If the type is tobuy stock, it confirms 1. The stock symbol is valid and has a share price that can beretrieved with getStockPriceBySymbol(). 2. The sourceAccount in the transaction record has sufficientfunds to cover the purchase. If the transaction is to sell stock,the function confirms: 1. The current stock is owned (one of the StockHolding recordscontains stock for the company mentioned in the transaction) 2. The StockHolding record has enough shares to cover the saleThe transaction should withdraw money from the sourceAccount (for apurchase) or add money for a sale. The transaction should be addedto the Transaction array in the account. If the transaction is accepted, the method returns true. Itreturns false, otherwise. public String toString(); This method formats and returns a string containing keyinformation. It should print the account number and suffix,separated by a ‘-‘. It should print the current value of theaccount (as computed by getValue()) but it should not print theindividual Stock holdings. The value is formatted to show USDollars and cents (i.e. $12345678.99 – no ‘,’ separators are neededbut decimal should be 2 digits.) In order to assure a consistentAPI, the accounts should implement one of two interfaces: • Savings – This interface (provided in Savings.java) requiresthe class to implement getAccountNumber(), getBalance() andaddTransaction(). • Investment – This interface (provided in Investment.java)requires the class to implement getValue() and addTransaction() Additional Requirements This is to be a production quality system. Thus, even thoughtransaction lists start with 100 slots for transactions, we have toprovide extra Transaction records when an overflow is about tooccur. So if the Transaction array is full, implement code(expandTransactions()) that will build a new array with 100additional transactions and copy the current array into the newarray which will now have 200 total transactions). The same appliesto StockHolding array in StockAccount. It should start with areasonable number (which is a team design choice) like 10 or 100.When it is about to overflow, create a new array with more objectsand copy the existing objects there. Testing Your code should be tested using the TestAccountManager classprovided. This will exercise the APIs and functionality you arerequired to provide. The output from this application should lookas follows: Trans: 0 : Type = Deposit : Amount = $ 1000.00 Trans: 1 : Type = PointOfSale : Amount = $ 15.53 Trans: 2 : Type = CheckCashed : Amount = $ 40.00 Trans: 3 : Type = Deposit : Amount = $ 2100.00 Trans: 4 : Type = PointOfSale : Amount = $ 10.05 Trans: 5 : Type = Interest : Amount = $ 0.37 Account: 12345-70, Owner: Joseph Cool, Balance: 3284.79 Invalid Transaction Type Account: 12345-73, Owner: Joseph Cool, Balance: 10016.93 Trans: 0 : Type = Deposit : Amount = $ 4100.00 Trans: 1 : Type = PointOfSale : Amount = $ 155.57 Trans: 2 : Type = CheckCashed : Amount = $ 50.00 Trans: 3 : Type = Deposit : Amount = $ 4250.50 Trans: 4 : Type = PointOfSale : Amount = $ 110.15 Trans: 5 : Type = Interest : Amount = $ 1.43 Account: 12346-70, Owner: Jane Doe, Balance: 9286.21Insufficient funds Account #: 12346-SA, Name=Jane Doe INTL 3 shares, Value= 256.50 HP 25 shares, Value= 250.00 APPL 2 shares, Value= 230.80 Account #: 12345-MF, Name=Joseph Cool Number of shares: 189.29 Value: 6625.00 Transaction: 0 : Type = buyMF Amount = 200.00 Transaction: 1 : Type = buyMF Amount = 300.00 Transaction: 2 : Type = sellMF Amount = 10.00 Transaction: 3 : Type = sellMF Amount = 15.00 Account: 12345-70, Owner: Joseph Cool, Balance: 3659.79 Account: 12346-70, Owner: Jane Doe, Balance: 8548.91 Account: 12345-73, Owner: Joseph Cool, Balance: 10016.93 mfa1: Value = $ 6625.00 sa2: Value = $ 737.30 public abstract class Account { private int number; private String ownerFirstName; private String ownerLastName; public Account(String firstName, String lastName, int accountNumber) { number = accountNumber; ownerFirstName = firstName; ownerLastName = lastName; } int getNumber() { return number; } public String getFirstName() { return ownerFirstName; } public String getLastName() { return ownerLastName; } public int getAccountNumber() { return number; } public String toString() { return “Account: ” + number + ” Owner: ” + ownerFirstName + ” ” + ownerLastName; }} . . .