package class9_1_FunctionalCircularNumbers_start;// Dr. Yoder. MSOE. 09 February 2017 import java.util.List; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Collectors; public class Driver { public static void main(String[] args) { Filter filter = new Filter(); filter.addPole(new Complex(1,0)); filter.addPole(new Complex(40,10)); filter.addPole(new Complex(3,4)); filter.addPole(new Complex(30,40)); filter.addPole(new Complex(20,10)); filter.addPole(new Complex(-50,0)); filter.addPole(new Complex(4,0)); // Write a code snippet that calls getSpecified() using a lambda expression // that produces true whenever the magnitude of the complex number is // greater than 27 for the predicate. // Predicate; filter.keepSpecified((Complex c)->{ if(c.getMagnitude()>27) { return true; } else { return false; } }); filter.getPoles().stream().filter( c->c.getMagnitude()>27) .forEach(c-> System.out.println("c = " + c)); List result = filter.getPoles().stream().filter( c->c.getMagnitude()>27) .collect(Collectors.toList()); System.out.println("result = " + result); List filtered = filter.getPoles(); // TODO stop crash System.out.println("The filtered filter:"); for (Complex c: filtered) { System.out.println("c = " + c); } //Consumer; filtered.forEach(complex->{ System.out.println("complex = " + complex); }); Predicate isReal = new Predicate() { @Override public boolean test(Complex complex) { return complex.getImaginary() == 0; } }; Predicate isReal2 = (Complex complex) -> { return complex.getImaginary() == 0; }; Predicate isReal3 = complex -> complex.getImaginary() == 0; // How to write a lambda expression } }