Create instances of each criterion class that user expresses


Problem

Prompt

1. 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.

2. 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);
}
}
}

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Create instances of each criterion class that user expresses
Reference No:- TGS03225417

Expected delivery within 24 Hours