////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* PIMS: Personal Invstment Management System Class : Investment Descrption: This class correspond to the entire Investment. Any access to investment (access/modification/edit portfolios/securities/ transaction etc.) is done through the instance of this class. the instance of this class The attributes are: 1> A list of all portfolio names. 2> Net-worth 3> ComputeNetWorth(): Returns the value of Net-Worth. Each time the Investment is accessed, the value of the Net-Worth is modified. 4> ComputeROI: Computes the ROI of a particular security 5> Add/Delete/Rename/Edit Portfolio/Security/Transaction */ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public class Investment{ private dataRepository DR; private CurrentValueSystem CVS; private String PortfolioList[];//A list of all portfolio names. private int NumPortfolios;//Number of portfolios private double NetWorth;//The networth of the investment. public Investment(dataRepository DR, CurrentValueSystem CVS)throws Exception{ this.DR = DR; this.CVS = CVS; //Initialize the portfolio list by reading from the //previously initialized file "portfolios" in the //HOME/.pims/Investment directory PortfolioList = DR.ReadPortfolioList(); //Count the number of portfolios. while(PortfolioList[NumPortfolios] != null)NumPortfolios++; } public boolean ReturnTypeOfSecurity(String PortfolioName, String SecurityName)throws Exception{ Portfolio port = new Portfolio(DR, CVS, PortfolioName); return(port.ReturnTypeOfSecurity(SecurityName)); } //Returns the list of portfolios public String[] ReturnPortfolioList()throws Exception{ return(PortfolioList); } //Returns the number of shares in a share type security. public int numShares(String PortfolioName, String SecurityName, int index)throws Exception{ Portfolio port = new Portfolio(DR, CVS, PortfolioName); return(port.numShares(SecurityName, index)); } //Returns the list of securities public SecurityDS[] ReturnSecurityList(String PortfolioName)throws Exception{ Portfolio port = new Portfolio(DR, CVS, PortfolioName); return(port.ReturnSecurityList()); } //Returns the list of transaction public Transaction[] ReturnTransactionList(String PortfolioName, String SecurityName)throws Exception{ Portfolio port = new Portfolio(DR, CVS, PortfolioName); return(port.ReturnTransactionList(SecurityName)); } //Returns the net worth of the investment public double ComputeNetWorth()throws Exception{ //Compute the NetWorth of the Investment NetWorth = 0.0; for(int i=0;i