Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/lambdas-MBuzzard87.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/libraries/Maven__junit_junit_4_12.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>groupId</groupId>
<artifactId>lambdas-MBuzzard87</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

</project>
6 changes: 6 additions & 0 deletions src/main/java/CheckPerson.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface CheckPerson {

boolean test(Person p);


}
13 changes: 13 additions & 0 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -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();

}
}
82 changes: 82 additions & 0 deletions src/main/java/Person.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import java.time.LocalDate;
import java.time.Period;
import java.util.List;

public class Person implements CheckPerson{
List<Person> 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());
}

}
14 changes: 14 additions & 0 deletions src/main/java/Search.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import java.util.List;

public class Search {

public static void printPersons(
List<Person> roster, CheckPerson tester) {
for (Person p : roster) {
if (tester.test(p)) {
p.printPerson();
}
}
}

}
84 changes: 84 additions & 0 deletions src/test/java/PersonTest.java
Original file line number Diff line number Diff line change
@@ -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();
//
// }
}
Binary file added target/classes/CheckPerson.class
Binary file not shown.
Binary file added target/classes/Main.class
Binary file not shown.
Binary file added target/classes/Person$Sex.class
Binary file not shown.
Binary file added target/classes/Person.class
Binary file not shown.
Binary file added target/classes/Search.class
Binary file not shown.
Binary file added target/test-classes/PersonTest.class
Binary file not shown.