Save Question 40 (15 points) Write a class called SeriesContainer that displays
ID: 3873190 • Letter: S
Question
Save Question 40 (15 points) Write a class called SeriesContainer that displays the numbers in multiple series. 2 numoff ms t counter that represents the number of series obiec in the Array. (related to partilly flled aray) 1. series An Array of Series Objects. 3. numOfTimes that represents how many numbers in each Series are printed 2. Parameterized Constructor 1. takes in an int parameter to set numofTimes. 2. takes in a parameter that represents the size of the array. 3. creates the array. 3. Methods 1. addSeries(Series newseries) 1. receives a new Series object as its parameters 2. adds the new Series object to the array. 2. toString) 1. returns a String that contains the numbers in all the series in the array. Each series is on its own line. 2. remember each series prints its values X number of times, where X is the numberofTimes parameterExplanation / Answer
public class SeriesContainer {
private Series series[];
private int numOfSeries;
private int numOfTimes;
private static int index = 0; // to store the series index value
public SeriesContainer(int numOfTimes, int size)
{
series = new Series[size];
this.numOfTimes = numOfTimes;
}
public void adddSeries(Series newSeries)
{
this.series[index] = newSeries;
index++;
}
public String toString()
{
String str = "";
for(int i = 0; i < series.length; i++)
{
str += "Series: #"+i+" "+numOfTimes+" "+Series.getValue();
}
return str;
}
}
SeriesContainer.javapublic class SeriesContainer {
private Series series[];
private int numOfSeries;
private int numOfTimes;
private static int index = 0; // to store the series index value
public SeriesContainer(int numOfTimes, int size)
{
series = new Series[size];
this.numOfTimes = numOfTimes;
}
public void adddSeries(Series newSeries)
{
this.series[index] = newSeries;
index++;
}
public String toString()
{
String str = "";
for(int i = 0; i < series.length; i++)
{
str += "Series: #"+i+" "+numOfTimes+" "+Series.getValue();
}
return str;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.