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
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions .idea/Lambdas2-ZCW.iml

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

11 changes: 11 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.

33 changes: 33 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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>com.zipcodewilmington.lambda</groupId>
<artifactId>Lambdas2</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>


</project>
3 changes: 3 additions & 0 deletions src/main/java/CheckPerson.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public interface CheckPerson {
boolean test(Person p);
}
56 changes: 56 additions & 0 deletions src/main/java/Person.java
Original file line number Diff line number Diff line change
@@ -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<Person> roster, int age) {
for (Person p : roster) {
if (p.getAge() >= age) {
p.printPerson(p.getName() + " is older than " + age);
}
}
}



}
49 changes: 49 additions & 0 deletions src/test/java/PersonTest.java
Original file line number Diff line number Diff line change
@@ -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<Person> testList = new ArrayList<>();
testList.add(person1);
testList.add(person2);

testPerson.printPersonsOlderThan(testList,28);


}
}