diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4151f93 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ + +# Default ignored files +/.idea/workspace.xml + +/target/ +.DS_Store +.classpath +.project +.settings +*.iml + +# User-specific stuff: +*.iml +.idea/** +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml diff --git a/.idea/Lambdas2-ZCW.iml b/.idea/Lambdas2-ZCW.iml new file mode 100644 index 0000000..4e3316b --- /dev/null +++ b/.idea/Lambdas2-ZCW.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..9896aeb --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..e15fd0e --- /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..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..0d16b85 --- /dev/null +++ b/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + + com.zipcodewilmington.lambda + Lambdas2 + 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + + + + + junit + junit + 4.12 + test + + + + + diff --git a/src/main/java/CheckPerson.java b/src/main/java/CheckPerson.java new file mode 100644 index 0000000..26a5bae --- /dev/null +++ b/src/main/java/CheckPerson.java @@ -0,0 +1,3 @@ +public interface CheckPerson { + boolean test(Person p); +} diff --git a/src/main/java/Person.java b/src/main/java/Person.java new file mode 100644 index 0000000..9917024 --- /dev/null +++ b/src/main/java/Person.java @@ -0,0 +1,56 @@ +import java.time.LocalDate; +import java.util.List; + +public class Person { + + public enum Sex { + MALE, FEMALE + } + + + private String name; + private LocalDate birthday; + private Sex gender; + private String emailAddress; + private Integer age; + + + public Person(String name, String emailAddress, Integer age, LocalDate birthday, Sex gender){ + this.age = age; + this.name = name; + this.birthday = birthday; + this.gender = gender; + this.emailAddress = emailAddress; + } + + public Person(){ + this.age = null; + this.name = null; + this.birthday = null; + this.gender = null; + this.emailAddress = null; + } + + public int getAge() { + return this.age; + } + + public String getName(){ + return this.name; + } + + private void printPerson(String message) { + System.out.print(message); + } + + public static void printPersonsOlderThan(List roster, int age) { + for (Person p : roster) { + if (p.getAge() >= age) { + p.printPerson(p.getName() + " is older than " + age); + } + } + } + + + +} diff --git a/src/test/java/PersonTest.java b/src/test/java/PersonTest.java new file mode 100644 index 0000000..9aeb700 --- /dev/null +++ b/src/test/java/PersonTest.java @@ -0,0 +1,49 @@ +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; + +public class PersonTest { + + + @Test + public void getAge() { + + Person testPerson = new Person("Joe",null,42,null, Person.Sex.MALE); + + Integer expected = 42; + Integer actual = testPerson.getAge(); + + Assert.assertEquals(expected,actual); + } + + @Test + public void getName() { + Person testPerson = new Person("Joe",null,42,null, Person.Sex.MALE); + + String expected = "Joe"; + String actual = testPerson.getName(); + + Assert.assertEquals(expected,actual); + } + + @Test + public void printPersonsOlderThan() { + Person person1 = new Person("Joe",null,42,null, Person.Sex.MALE); + Person person2 = new Person("John",null,24,null, Person.Sex.MALE); + Person testPerson = new Person(); + + List testList = new ArrayList<>(); + testList.add(person1); + testList.add(person2); + + testPerson.printPersonsOlderThan(testList,28); + + + } +} \ No newline at end of file