Question
In Java** Prompt First, move the prompting and gathering of information needed for each criterion into the code for each criterion class. You'll want to
In Java**
Prompt
- First, move the prompting and gathering of information needed for each criterion into the code for each criterion class. You'll want to implement a static method in each class that returns an instance of the class. You'll then need to change the Test class to use those static methods to create instances of each criterion class that the user expresses interest in using instead of using the class' constructor.
- Second, add a "less than or equal to" comparison test that can be used by each of the numeric criterion classes.
Code
public class AmplitudeCriterion implements BlinkSelectionCriterion
{
private ComparisonSpecification comparisonSpec;
private int criterionValue;
public AmplitudeCriterion(ComparisonSpecification spec, int value) {
this.comparisonSpec = spec;
this.criterionValue = value;
}
public boolean doesBlinkMatch(Blink blink) {
int valueToCheck = blink.getAmplitude();
switch (this.comparisonSpec) {
case LESS_THAN:
return valueToCheck < criterionValue;
case GREATER_THAN:
return valueToCheck > criterionValue;
default:
throw new IllegalArgumentException("Unrecognized Comparision: " + comparisonSpec);
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started