diff --git a/pom.xml b/pom.xml index 6d56659..c87f792 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,18 @@ com.zipcodewilmington person 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 14 + 14 + + + + junit diff --git a/src/main/java/com/zipcodewilmington/person/Person.java b/src/main/java/com/zipcodewilmington/person/Person.java index c12425f..54a3f30 100644 --- a/src/main/java/com/zipcodewilmington/person/Person.java +++ b/src/main/java/com/zipcodewilmington/person/Person.java @@ -4,32 +4,72 @@ * Created by leon on 2/12/18. */ public class Person { + private Double gpa; private String name; private int age; + private Integer height; public Person() { + this.name = ""; + this.age = Integer.MAX_VALUE; } public Person(int age) { + this.age = age; } public Person(String name) { + this.name = name; } public Person(String name, int age) { + this.name = name; + this.age = age; + + } + + public Person(String name, int age, Integer height) { + this.name = name; + this.age = age; + this.height = height; + } + + public Person(String name, Integer age, Integer height, Double gpa) { + this.name = name; + this.age = age; + this.height = height; + this.gpa = gpa; } - public void setName(String name) { + public void setName(String newName) { + this.name = newName; } - public void setAge(int age) { + public void setAge(int newAge) { + this.age = newAge; } public String getName() { - return null; + + return name; } public Integer getAge() { - return null; + return age; + } + + + + public Integer getHeight() { + return height; + } + + + public void setHeight(Integer height) { + this.height = height; + } + + public Double getGPA() { + return gpa; } } diff --git a/src/test/java/com/zipcodewilmington/person/TestPerson.java b/src/test/java/com/zipcodewilmington/person/TestPerson.java index 59af3b2..04b71c9 100644 --- a/src/test/java/com/zipcodewilmington/person/TestPerson.java +++ b/src/test/java/com/zipcodewilmington/person/TestPerson.java @@ -95,4 +95,49 @@ public void testSetAge() { Integer actual = person.getAge(); Assert.assertEquals(expected, actual); } + + @Test + public void testGetHeight() { + //Given + Integer expectedAge =25; + String expectedName = "Dione"; + Integer expectedHeight = 68; + + //When + Person person = new Person(expectedName, expectedAge, expectedHeight); + + //Then + Integer actual = person.getHeight(); + Assert.assertEquals(expectedHeight, actual); + } + + @Test + public void testSetHeight() { + //Given + Person person = new Person(); + Integer expected = 70; + + //When + person.setHeight(expected); + + //Then + Integer actual = person.getHeight(); + Assert.assertEquals(expected, actual); + } + + @Test + public void testGetGPA() { + //Given + Integer expectedAge =25; + String expectedName = "Dione"; + Integer expectedHeight = 68; + Double expectedGPA = 3.8; + + //When + Person testperson = new Person(expectedName,expectedAge,expectedHeight, expectedGPA); + + //Then + Double actual = testperson.getGPA(); + Assert.assertEquals(expectedGPA, actual); + } }