diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..be99434 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/lambdas-MBuzzard87.iml b/.idea/lambdas-MBuzzard87.iml new file mode 100644 index 0000000..975d5da --- /dev/null +++ b/.idea/lambdas-MBuzzard87.iml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__junit_junit_4_12.xml b/.idea/libraries/Maven__junit_junit_4_12.xml new file mode 100644 index 0000000..d411041 --- /dev/null +++ b/.idea/libraries/Maven__junit_junit_4_12.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml new file mode 100644 index 0000000..f58bbc1 --- /dev/null +++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e8942bd --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f9d2a56 --- /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/pom.xml b/pom.xml new file mode 100644 index 0000000..c4b34ed --- /dev/null +++ b/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + groupId + lambdas-MBuzzard87 + 1.0-SNAPSHOT + + + junit + junit + 4.12 + test + + + + + 8 + 8 + + + \ No newline at end of file diff --git a/src/main/java/CheckPerson.java b/src/main/java/CheckPerson.java new file mode 100644 index 0000000..4ce6bec --- /dev/null +++ b/src/main/java/CheckPerson.java @@ -0,0 +1,6 @@ +interface CheckPerson { + + boolean test(Person p); + + +} \ No newline at end of file diff --git a/src/main/java/Main.java b/src/main/java/Main.java new file mode 100644 index 0000000..1635427 --- /dev/null +++ b/src/main/java/Main.java @@ -0,0 +1,13 @@ +import java.time.LocalDate; + +public class Main { + + + public static void main(String[] args) { + LocalDate birthday = LocalDate.of(1987,2,7); + Person person = new Person("Mike", birthday, Person.Sex.MALE, "mbuzz@gmail.com"); + + person.printPerson(); + + } +} diff --git a/src/main/java/Person.java b/src/main/java/Person.java new file mode 100644 index 0000000..9934e69 --- /dev/null +++ b/src/main/java/Person.java @@ -0,0 +1,82 @@ +import java.time.LocalDate; +import java.time.Period; +import java.util.List; + +public class Person implements CheckPerson{ + List personList; + + + public enum Sex { + MALE, FEMALE + } + + + String name; + LocalDate birthday; + Sex gender; + String emailAddress; + + public Person(String name, LocalDate birthday, Sex gender, String emailAddress) { + this.name = name; + this.birthday = birthday; + this.gender = gender; + this.emailAddress = emailAddress; + } + + public Person() { + } + + public int getAge(LocalDate birthday) { + this.birthday = birthday; + LocalDate currentDate = LocalDate.now(); + Period currentAge = Period.between(birthday,currentDate); + return currentAge.getYears(); + } + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + public Sex getGender() { + return gender; + } + + public void setGender(Sex gender) { + this.gender = gender; + } + + + public String getEmailAddress() { + return emailAddress; + } + + public void setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + } + + @Override + public boolean test(Person p) { + return true; + } + + @Override + public String toString() { + return "Person{" + + "name='" + name + '\'' + + ", birthday=" + birthday + + ", gender=" + gender + + ", emailAddress='" + emailAddress + '\'' + + '}'; + } + + public void printPerson() { + System.out.println(this.toString()); + } + +} \ No newline at end of file diff --git a/src/main/java/Search.java b/src/main/java/Search.java new file mode 100644 index 0000000..e4d669e --- /dev/null +++ b/src/main/java/Search.java @@ -0,0 +1,14 @@ +import java.util.List; + +public class Search { + + public static void printPersons( + List roster, CheckPerson tester) { + for (Person p : roster) { + if (tester.test(p)) { + p.printPerson(); + } + } + } + +} diff --git a/src/test/java/PersonTest.java b/src/test/java/PersonTest.java new file mode 100644 index 0000000..06037b0 --- /dev/null +++ b/src/test/java/PersonTest.java @@ -0,0 +1,84 @@ +import junit.framework.TestCase; + +import java.io.PrintStream; +import java.time.LocalDate; + + +public class PersonTest extends TestCase { + + LocalDate birthday = LocalDate.of(1987,2,7); + Person testPerson = new Person("Mike", birthday, Person.Sex.MALE, "mbuzz@gmail.com"); + + public void testGetAge() { + int expectedAge = 33; + int actualAge = testPerson.getAge(birthday); + + assertEquals(expectedAge,actualAge); + } + + public void testTestGetName() { + String expectedName = "Mike"; + String actualName = testPerson.getName(); + + assertEquals(expectedName,actualName); + } + + public void testTestSetName() { + testPerson.setName("Billy Bob"); + String expectedName = "Billy Bob"; + String actualName = testPerson.getName(); + + assertEquals(expectedName,actualName); + } + + public void testGetGender() { + Person.Sex expectedMale = Person.Sex.MALE; + Person.Sex actual = testPerson.getGender(); + + assertEquals(expectedMale,actual); + } + + public void testSetGender() { + + testPerson.setGender(Person.Sex.FEMALE); + Person.Sex expectedGender = Person.Sex.FEMALE; + Person.Sex actualGender = testPerson.getGender(); + + assertEquals(expectedGender,actualGender); + } + + public void testGetEmailAddress() { + String expectedEmail = "mbuzz@gmail.com"; + String actualEmail = testPerson.getEmailAddress(); + + assertEquals(expectedEmail,actualEmail); + } + + public void testSetEmailAddress() { + testPerson.setEmailAddress("hello@compuserve.com"); + String expectedEmail = "hello@compuserve.com"; + String actualEmail = testPerson.getEmailAddress(); + + assertEquals(expectedEmail,actualEmail); + } + + public void testTest1() { + + } + + public void testTestToString() { + String actualStr = testPerson.toString(); + String expectedStr = "Person{name='Mike', birthday=1987-02-07, gender=MALE, emailAddress='mbuzz@gmail.com'}"; + + assertEquals(expectedStr,actualStr); + } + +// public void testPrintPerson() { +// PrintStream standardOut = new PrintStream(System.out); +// +// +// +// String expectedPrint = testPerson.toString(); +// +// } +} \ No newline at end of file diff --git a/target/classes/CheckPerson.class b/target/classes/CheckPerson.class new file mode 100644 index 0000000..41ced47 Binary files /dev/null and b/target/classes/CheckPerson.class differ diff --git a/target/classes/Main.class b/target/classes/Main.class new file mode 100644 index 0000000..f4f5549 Binary files /dev/null and b/target/classes/Main.class differ diff --git a/target/classes/Person$Sex.class b/target/classes/Person$Sex.class new file mode 100644 index 0000000..9fab979 Binary files /dev/null and b/target/classes/Person$Sex.class differ diff --git a/target/classes/Person.class b/target/classes/Person.class new file mode 100644 index 0000000..2cb0b4b Binary files /dev/null and b/target/classes/Person.class differ diff --git a/target/classes/Search.class b/target/classes/Search.class new file mode 100644 index 0000000..1e2f1d7 Binary files /dev/null and b/target/classes/Search.class differ diff --git a/target/test-classes/PersonTest.class b/target/test-classes/PersonTest.class new file mode 100644 index 0000000..2c0c6be Binary files /dev/null and b/target/test-classes/PersonTest.class differ