Reflection and Solutions of the FRQ
public interface NumberGroup
{
public boolean contains(int num);
}
// Range functionality I got from rachit
public class Range implements NumberGroup {
private int min;
private int max;
public Range(int min, int max) {
this.min = min;
this.max = max;
}
@Override
public boolean contains(int num) {
if (num >= min && num <= max) {
return true;
} else {
return false;
}
}
}
//Proof it works
public class Main {
public static void main(String[] args) {
NumberGroup range = new Range(5, 10);
System.out.println(range.contains(2));
System.out.println(range.contains(7));
System.out.println(range.contains(4));
}
}
Main.main(null);
false
true
false
// Proof it works
public class groups {
public static void main(String[] args) {
Range range1 = new Range(5, 8);
Range range2 = new Range(10, 12);
Range range3 = new Range(1, 6);
System.out.println(range1.contains(3));
System.out.println(range2.contains(12));
System.out.println(range3.contains(7));
System.out.println(range1.contains(7));
}
}
groups.main(null);
false
true
false
true