Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Constructor # 1 - Takes a start value ( must be 1 or greater ) , number of terms ( must be 3 or greater

Constructor #1- Takes a start value (must be 1 or greater), number of terms (must be 3 or greater), and a value for step (must be 1 or greater). If an invalid value is passed in, an IllegalArgumentException will be thrown with the message Invalid parameter and further initialization will not take place. If all the arguments are valid, it initializes the corresponding instance variables and assigns a value to seq (see output for details).
Constructor #2- Takes a start value (must be 1 or greater) and a value for step (must be 1 or greater). If an invalid value is passed in, an IllegalArgumentException will be thrown with the message Invalid parameter and further initialization will not take place. If all the arguments are valid, it assumes the number of terms is five and assigns a value to seq (see output for details).
Copy Constructor - Define a copy constructor for the class.
getStep - Get method for step.
setStep - Set method for step. An IllegalArgumentException will be thrown with the message Invalid parameter and further initialization will not take place if an attempt is made to make step be an integer less than 1. Do not forget to update seq to match the new step value.
getMatchCount - Get method for matchCount.
setMatchCount - Set method for number of matchCount. An IllegalArgumentException will be thrown with the message Invalid parameter and further initialization will not take place if an attempt is made to make matchCount be an integer less than 1.
equals - Define an equals method for the class. In our bizarre definition of sequence equality (do not tell your math teacher about this (), we will assume 2 sequences to be equal if they have at least matchCount terms in common. The placement of terms do not have to match. For example, if matchCount is 3, the sequence 1,2,3,4,55,6 and 2,4,6,8 would be equal because there are at least 3 number (i.e.2,4, and 6) that show up in both sequences. For the same example, the sequences would not be equal had matchCount been set to 4.
compareTo - This method will allow us to compare two aSeq objects. It has a aSeq as parameter and returns an integer. The aSeq compareTo method will return:
a. A negative value if the arithmetic series (sum of the terms in the sequence) of the current object is less than the parameter.
b. A positive value if the arithmetic series (sum of the terms in the sequence) of the current object is greater than the parameter.
c.0 otherwise.
toString - Given to you. Make no changes to this or you will fail the tests.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

978-0764535376

More Books

Students also viewed these Databases questions