Question: A financial institution wants to develop a Java application to track its investment portfolios. Each portfolio contains 2 asset types: stocks and bonds. Each asset

A financial institution wants to develop a Java application to track its investment portfolios. Each portfolio contains 2 asset types: stocks and bonds. Each asset has specific attributes like ticker symbol, purchase price, current price, and quantity. The application needs to calculate the total value of each asset and the overall portfolio value. You are required to develop a Java application that can perform the following functions:
Define: Design Java classes for Assets, Portfolio, Stocks, and Bonds.
Create: Implement methods to create Asset objects with relevant attributes and Portfolio objects holding the references to multiple Asset types.
Update: Include methods to update the current price of an Asset and calculate its new value.
Portfolio valuation: Create methods to calculate the total value of a Portfolio considering all it's assets current price.
Please refer to the following UML diagram for reference:
Diagram 2.1 UML diagram.
Additionally, use this outline to help you solve the problem:
Classes:
Asset:
Attributes: symbol, purchasePrice, currentPrice, quantity
Methods: calculateValue(), updatePrice(newPrice), calculateReturn.
Portfolio:
Attributes: name, Asset (ArrayList of Asset Objects).
Methods: getTotalValue(), addAsset(asset), updateAssetPrice(symbol, newPrice).
Stock: (inherit from Asset)
Attributes: dividendYield
Methods: getAdditionalAttributes()(display the dividen)
Bond: (inherit from Asset)
Attributes: interestRate, maturityDate
Methods: getAdditional Attributes()(display interest rate and date).
To display the output, create a test class call main. In this class you have the following methods:
testAddAsset(): Add asset to portfolio using the method addAsset. The asset type can either be a stock asset or bond. After adding the asset, display the size of the asset arrayList and the content. Use the following values depending on the type of asset that is being added:
Stock: AAPL", 100.0,150.0,10,0.02
Bond: "US10YT",1000.0,1020.0,5,0.05
Refer to the table 2.1 below for more information:
Table 2.1: Asset type input details
\table[[\table[[Asset],[Type]],Symbol,\table[[Purchase],[Price]],\table[[Current],[Price]],Quantity,\table[[Dividend],[Yield]],\table[[Interest],[rate]],\table[[Maturity],[date]]],[Stock,AAPL,100,150,10,0.02,-,-],[Bond,US10YT,1000,1020,5,-,0.05,\table[[Current],[date]]]]
testGetTotalValue(): after adding the asset to the portfolio, use the method calculateValue() from the asset which in turn can be check with the portfolio method getTotalValue(). If the value return from the calculateValue() is the same as getTotalValue(), then it pass the test.
testUpdatePrice(): After adding the asset to the portfolio, set a new price for the asset using the updatePrice() method. Then display the value of the portfolio.
A financial institution wants to develop a Java application to track its investment portfolios. Each portfolio contains 2 asset types: stocks and bonds. Each asset has specific attributes like ticker symbol, purchase price, current price, and quantity. The application needs to calculate the total value of each asset and the overall portfolio value. You are required to develop a Java application that can perform the following functions:
Define: Design Java classes for Assets, Portfolio, Stocks, and Bonds.
Create: Implement methods to create Asset objects with relevant attributes and Portfolio objects holding the references to multiple Asset types.
Update: Include methods to update the current price of an Asset and calculate its new value.
Portfolio valuation: Create methods to calculate the total value of a Portfolio considering all it's assets current price.
Please refer to the following UML diagram for reference:
Diagram 2.1 UML diagram.
 A financial institution wants to develop a Java application to track

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!