Week 9
Class Activity
## Complex Class For these activities you will be using this [__`Complex`__](Complex.java) class. ## Activity 1 Implement a method, `getReal()`, that accepts a `List<Complex>` and returns a list of all the complex numbers where the imaginary component is zero. ## Activity 2 Write a class, `IsReal`, that implements the [`Predicate<Complex>`](https://docs.oracle.com/javase/8/docs/api/java/util/function/Predicate.html) interface. The `test()` method must return `true` if and only if the imaginary component of the complex number is zero. ## Activity 3 Write a method, `getSpecified()`, that accepts a `List<Complex>` and a `Predicate<Complex>` and returns a list of all the complex numbers for which the predicate is true. ## Activity 4 Write a code snippet that calls `getSpecified()` using an `IsReal` object. Then rewrite the call using a lambda expression instead of an `IsReal` object. ## Activity 5 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. ## Activity 6 Make use of a [`Stream`](https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html) to generate the same list as required by the previous problem. You may not use `getSpecified()`. Instead you should use `Stream.filter()` and `Stream.collect()`. ## Activity 7 Use the `List.forEach()` method to display each complex number on a separate line. ## Activity 8 Make use of a `Stream` and `DoubleStream` to calculate the average angle, in degrees, of the complex numbers in a list.

Monday, 05-Feb-2018 06:24:20 CST