Question: Java Programming Goals In this lab students continue to write programs using multiple classes. By the end of this lab, students should be able to

Java Programming

Goals

In this lab students continue to write programs using multiple classes. By the end of this lab, students should be able to

Write classes that use arrays and ArrayLists of objects as instance variables

Write methods that process arrays and ArrayLists of objects

Write getter and setter methods for instance variables

Write methods using object parameters and primitive types

Question-

This program uses the StockHolding class that we wrote in the lab for Writing Classes.

Write a class PortfolioList. A PortfolioList object maintains a portfolio of StockHolding objects. A PortfolioList

keeps an ArrayList

has a no-argument constructor

mutators: 
void add(StockHolding stock) // adds the given StockHolding to the portfolio 
void remove(String ticker) // removes the StockHolding with the given ticker from the portfolio 
accessors: 
StockHolding find(String ticker) // returns a reference to the portfolio element having the given ticker. The method should return null if there is no such element 
String toString() // returns a string containing the toString values of each element separated by newline characters ( ) Note:For manipulating the ArrayList of StockHolding objects, use only ArrayList's add, get, size and remove methods. Write a class PortfolioDriver that contains only a main method. The main method should create two PortfolioList objects. It should add two StockHolding objects to one portfolio, and 4 to the other. It should print both portfolios. It should find and print the toString value of a stock in one portfolio. It should delete all of the StockHolding objects from the portfolio with 4 objects, and print the portfolio. 

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!