Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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 parameter

Explanation / 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.java

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;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote