Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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 UML diagram.
Additionally, use this outline to help you solve the problem:
Classes:
Asset:
Attributes: symbol, purchasePrice, currentPrice, quantity
Methods: calculateValue updatePricenewPrice calculateReturn.
Portfolio:
Attributes: name, Asset ArrayList of Asset Objects
Methods: getTotalValue addAssetasset updateAssetPricesymbol newPrice
Stock: inherit from Asset
Attributes: dividendYield
Methods: getAdditionalAttributesdisplay the dividen
Bond: inherit from Asset
Attributes: interestRate, maturityDate
Methods: getAdditional Attributesdisplay 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",
Bond: USYT
Refer to the table below for more information:
Table : Asset type input details
tabletableAssetTypeSymbol,tablePurchasePricetableCurrentPriceQuantity,tableDividendYieldtableInterestratetableMaturitydateStockAAPL,BondUSYTtableCurrentdate
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 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 UML diagram.
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