diff --git a/.idea/Lambdas2-ZCW.iml b/.idea/Lambdas2-ZCW.iml
new file mode 100644
index 0000000..401d072
--- /dev/null
+++ b/.idea/Lambdas2-ZCW.iml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..15a15b2
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..4f50da6
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..e080e35
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..4a05228
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,650 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ current
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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of file
diff --git a/src/main/java/lambdaslab/Check.java b/src/main/java/lambdaslab/Check.java
new file mode 100644
index 0000000..bea9d8e
--- /dev/null
+++ b/src/main/java/lambdaslab/Check.java
@@ -0,0 +1,29 @@
+package lambdaslab;
+
+public class Check implements CheckPerson {
+ Integer method;
+
+ public Check(Integer method) {
+ this.method = method;
+ }
+
+ public Boolean test(Person person) {
+ switch (method) {
+ case 0:
+ return checkIfMale(person);
+ case 1:
+ return checkIfOlderThan(person, 42);
+ default:
+ return false;
+ }
+ }
+
+ public Boolean checkIfMale(Person p) {
+ return (p.getGender().equals(Person.Sex.MALE));
+ }
+
+ public Boolean checkIfOlderThan(Person p, Integer age) {
+ return (p.getAge() >= age);
+ }
+
+}
diff --git a/src/main/java/lambdaslab/CheckPerson.java b/src/main/java/lambdaslab/CheckPerson.java
new file mode 100644
index 0000000..d724ae0
--- /dev/null
+++ b/src/main/java/lambdaslab/CheckPerson.java
@@ -0,0 +1,5 @@
+package lambdaslab;
+
+public interface CheckPerson {
+ Boolean test(Person p);
+}
diff --git a/src/main/java/lambdaslab/Person.java b/src/main/java/lambdaslab/Person.java
new file mode 100644
index 0000000..6e24aaf
--- /dev/null
+++ b/src/main/java/lambdaslab/Person.java
@@ -0,0 +1,109 @@
+package lambdaslab;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+
+public class Person {
+ public enum Sex {
+ MALE, FEMALE
+ }
+
+ String name;
+ LocalDate birthday;
+ Sex gender;
+ String emailAddress;
+ Boolean test = false;
+ public Person () {}
+
+ public Person (String name, Sex gender, LocalDate birthday, String emailAddress) {
+ this.name = name;
+ this.gender = gender;
+ this.birthday = birthday;
+ this.emailAddress = emailAddress;
+ }
+
+ public Person (String name, Sex gender, LocalDate birthday) {
+ this.name = name;
+ this.gender = gender;
+ this.birthday = birthday;
+ this.emailAddress = name.split(" ")[0] + "@email.com";
+ }
+
+ public Person(String name, Sex gender, Integer yyyy, Integer mm, Integer dd) {
+ this(name, gender, LocalDate.of(yyyy,mm,dd));
+ }
+
+ public Person(String name, Sex gender, Integer yyyy, Integer mm, Integer dd, Boolean test) {
+ this(name, gender, LocalDate.of(yyyy,mm,dd));
+ this.test = test;
+ }
+
+ public Person (String name, Sex gender, LocalDate birthday, String emailAddress, Boolean test) {
+ this(name, gender, birthday, emailAddress);
+ this.test = test;
+ }
+
+ public LocalDate getNow() {
+ return test ? LocalDate.of(2019, 12, 1) : LocalDate.now();
+ }
+
+ public Integer getAge() {
+ return getNow().compareTo(birthday);
+ }
+
+
+
+ public String toString() {
+ return (String.format("\nPerson:\n" +
+ "\tName:\t\t%s\n" +
+ "\tSex:\t\t%s\n" +
+ "\tBirthday:\t%s\n" +
+ "\tEmail:\t\t%s\n",
+ this.getName(), this.getGender().name(),
+ this.getBirthday().format(DateTimeFormatter.ofPattern("MM-dd-yyyy")),
+ this.getEmailAddress()));
+ }
+
+ public void printPerson() {
+ System.out.println(this.toString());
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Sex getGender() {
+ return this.gender;
+ }
+
+ public void setGender(Sex gender) {
+ this.gender = gender;
+ }
+
+ public LocalDate getBirthday() {
+ return this.birthday;
+ }
+
+ public void setBirthday(LocalDate date) {
+ this.birthday = date;
+ }
+
+ public void setBirthday(Integer year, Integer month, Integer day) {
+ this.birthday = LocalDate.of(year, month, day);
+ }
+
+ public String getEmailAddress() {
+ return this.emailAddress;
+ }
+
+ public void setEmailAddress(String emailAddress) {
+ this.emailAddress = emailAddress;
+ }
+
+
+
+}
diff --git a/src/main/java/lambdaslab/PersonWareHouse.java b/src/main/java/lambdaslab/PersonWareHouse.java
new file mode 100644
index 0000000..407abcd
--- /dev/null
+++ b/src/main/java/lambdaslab/PersonWareHouse.java
@@ -0,0 +1,24 @@
+package lambdaslab;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.List;
+
+import static lambdaslab.Person.Sex.*;
+
+public class PersonWareHouse {
+ List roster;
+
+ public PersonWareHouse () {
+ roster = new ArrayList<>();
+ roster.add(new Person("Wes", MALE,1980,5,22, true));
+ roster.add(new Person("Kai", FEMALE, 1970, 4, 2, true));
+ roster.add(new Person("Ryan", MALE, 1960, 2,29, true));
+ roster.add(new Person("Val", FEMALE, 1990, 6,10, true));
+ roster.add(new Person("Kendra", FEMALE, 2000, 3,30, true));
+ }
+
+ public List getRoster() {
+ return this.roster;
+ }
+}
diff --git a/src/main/java/lambdaslab/Search.java b/src/main/java/lambdaslab/Search.java
new file mode 100644
index 0000000..a245095
--- /dev/null
+++ b/src/main/java/lambdaslab/Search.java
@@ -0,0 +1,67 @@
+package lambdaslab;
+
+import java.time.LocalDate;
+import java.util.List;
+import java.util.function.Predicate;
+
+public class Search {
+ public static String printPersonsOlderThan(List roster, Integer age) {
+ StringBuilder out = new StringBuilder();
+ roster.stream().filter(p -> p.getAge() >= age).forEach(person -> {
+ out.append(person.toString()+"\n");
+ person.printPerson();
+ });
+ return out.toString();
+ }
+
+ public static String printPersonsWithinAgeRange(List roster, Integer low, Integer high) {
+ StringBuilder out = new StringBuilder();
+ roster.stream()
+ .filter(p -> p.getAge() >= low && p.getAge() <= high)
+ .forEach(person -> {
+ out.append(person.toString()+"\n");
+ person.printPerson();
+ });
+ return out.toString();
+ }
+
+ public static String printPersons(List roster, CheckPerson tester) {
+ StringBuilder out = new StringBuilder();
+ roster.stream()
+ .filter(p -> tester.test(p))
+ .forEach(p -> {
+ p.printPerson();
+ out.append(p.toString());
+ });
+ return out.toString();
+ }
+
+ // Example using Local Class
+ static class CheckAge implements CheckPerson {
+ @Override
+ public Boolean test(Person person) {
+ return (person.getAge() >= 42);
+ }
+ }
+
+ public static String exWithLocalClass(List roster) {
+ return printPersons(roster, new CheckAge());
+ }
+
+ public static String exWithLambdas(List roster) {
+ return printPersons(roster, person -> person.getAge() >= 42);
+ }
+
+ public static String exWithAnonClass(List roster) {
+ return printPersons(roster, new CheckPerson() {
+ @Override
+ public Boolean test(Person p) {
+ return p.getGender().equals(Person.Sex.MALE);
+ }
+ });
+ }
+
+
+
+
+}
diff --git a/src/test/java/lambdaslab/testPerson.java b/src/test/java/lambdaslab/testPerson.java
new file mode 100644
index 0000000..e8a7b23
--- /dev/null
+++ b/src/test/java/lambdaslab/testPerson.java
@@ -0,0 +1,34 @@
+package lambdaslab;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.time.LocalDate;
+
+public class testPerson {
+ Person person;
+
+ @Before
+ public void setUp() {
+ person = new Person("Wes", Person.Sex.MALE, LocalDate.of(1997, 8, 5), "wes@jones.com", true);
+ }
+
+ @Test
+ public void testGetAge() {
+ Integer actual = person.getAge();
+ Integer expected = 22;
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testPrintPerson() {
+ String actual = person.toString();
+ String expected = "\nPerson:\n" +
+ "\tName:\t\tWes\n" +
+ "\tSex:\t\tMALE\n" +
+ "\tBirthday:\t08-05-1997\n" +
+ "\tEmail:\t\twes@jones.com\n";
+ Assert.assertEquals(expected, actual);
+ }
+}
diff --git a/src/test/java/lambdaslab/testSearch.java b/src/test/java/lambdaslab/testSearch.java
new file mode 100644
index 0000000..0d940e8
--- /dev/null
+++ b/src/test/java/lambdaslab/testSearch.java
@@ -0,0 +1,103 @@
+package lambdaslab;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+
+public class testSearch {
+ List roster;
+
+ @Before
+ public void setUp() {
+ PersonWareHouse pw = new PersonWareHouse();
+ roster = pw.getRoster();
+ }
+
+ @Test
+ public void testExWithLocalClass() {
+ // get Persons with age >= 42
+ String actual = Search.exWithLocalClass(roster);
+ String expected = "\n" +
+ "Person:\n" +
+ "\tName:\t\tKai\n" +
+ "\tSex:\t\tFEMALE\n" +
+ "\tBirthday:\t04-02-1970\n" +
+ "\tEmail:\t\tKai@email.com\n" +
+ "\n" +
+ "Person:\n" +
+ "\tName:\t\tRyan\n" +
+ "\tSex:\t\tMALE\n" +
+ "\tBirthday:\t02-29-1960\n" +
+ "\tEmail:\t\tRyan@email.com\n";
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testExWithLambdas() {
+ // get Persons with age >= 42
+ String actual = Search.exWithLambdas(roster);
+ String expected = "\n" +
+ "Person:\n" +
+ "\tName:\t\tKai\n" +
+ "\tSex:\t\tFEMALE\n" +
+ "\tBirthday:\t04-02-1970\n" +
+ "\tEmail:\t\tKai@email.com\n" +
+ "\n" +
+ "Person:\n" +
+ "\tName:\t\tRyan\n" +
+ "\tSex:\t\tMALE\n" +
+ "\tBirthday:\t02-29-1960\n" +
+ "\tEmail:\t\tRyan@email.com\n";
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testExWithAnonClass() {
+ // get Persons with gender MALE
+ String actual = Search.exWithAnonClass(roster);
+ String expected = "\n" +
+ "Person:\n" +
+ "\tName:\t\tWes\n" +
+ "\tSex:\t\tMALE\n" +
+ "\tBirthday:\t05-22-1980\n" +
+ "\tEmail:\t\tWes@email.com\n" +
+ "\n" +
+ "Person:\n" +
+ "\tName:\t\tRyan\n" +
+ "\tSex:\t\tMALE\n" +
+ "\tBirthday:\t02-29-1960\n" +
+ "\tEmail:\t\tRyan@email.com\n";
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testPrintPersonsOlderThan() {
+ Integer actual = Search.printPersonsOlderThan(roster, 40).length();
+ Integer expected = 162;
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testPrintPersonsWithinAgeRange() {
+ Integer actual = Search.printPersonsWithinAgeRange(roster, 25, 55).length();
+ Integer expected = 241;
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testPrintPersons1() {
+ Integer actual = Search.printPersons(roster, new Check(0)).length();
+ Integer expected = 158;
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testPrintPersons2() {
+ Integer actual = Search.printPersons(roster, new Check(1)).length();
+ Integer expected = 160;
+ Assert.assertEquals(expected, actual);
+ }
+
+}
diff --git a/target/production/Lambdas2-ZCW/lambdaslab/Check.class b/target/production/Lambdas2-ZCW/lambdaslab/Check.class
new file mode 100644
index 0000000..231ad27
Binary files /dev/null and b/target/production/Lambdas2-ZCW/lambdaslab/Check.class differ
diff --git a/target/production/Lambdas2-ZCW/lambdaslab/CheckPerson.class b/target/production/Lambdas2-ZCW/lambdaslab/CheckPerson.class
new file mode 100644
index 0000000..6840503
Binary files /dev/null and b/target/production/Lambdas2-ZCW/lambdaslab/CheckPerson.class differ
diff --git a/target/production/Lambdas2-ZCW/lambdaslab/Person$Sex.class b/target/production/Lambdas2-ZCW/lambdaslab/Person$Sex.class
new file mode 100644
index 0000000..b96d470
Binary files /dev/null and b/target/production/Lambdas2-ZCW/lambdaslab/Person$Sex.class differ
diff --git a/target/production/Lambdas2-ZCW/lambdaslab/Person.class b/target/production/Lambdas2-ZCW/lambdaslab/Person.class
new file mode 100644
index 0000000..a4bbfa7
Binary files /dev/null and b/target/production/Lambdas2-ZCW/lambdaslab/Person.class differ
diff --git a/target/production/Lambdas2-ZCW/lambdaslab/PersonWareHouse.class b/target/production/Lambdas2-ZCW/lambdaslab/PersonWareHouse.class
new file mode 100644
index 0000000..7da6722
Binary files /dev/null and b/target/production/Lambdas2-ZCW/lambdaslab/PersonWareHouse.class differ
diff --git a/target/production/Lambdas2-ZCW/lambdaslab/Search.class b/target/production/Lambdas2-ZCW/lambdaslab/Search.class
new file mode 100644
index 0000000..4c43274
Binary files /dev/null and b/target/production/Lambdas2-ZCW/lambdaslab/Search.class differ
diff --git a/target/test/Lambdas2-ZCW/lambdaslab/testPerson.class b/target/test/Lambdas2-ZCW/lambdaslab/testPerson.class
new file mode 100644
index 0000000..22ddd67
Binary files /dev/null and b/target/test/Lambdas2-ZCW/lambdaslab/testPerson.class differ
diff --git a/target/test/Lambdas2-ZCW/lambdaslab/testSearch.class b/target/test/Lambdas2-ZCW/lambdaslab/testSearch.class
new file mode 100644
index 0000000..08d6f14
Binary files /dev/null and b/target/test/Lambdas2-ZCW/lambdaslab/testSearch.class differ