Skip to content

the default constructer fixed #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
<groupId>com.zipcodewilmington</groupId>
<artifactId>person</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>14</source>
<target>14</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
Expand Down
48 changes: 44 additions & 4 deletions src/main/java/com/zipcodewilmington/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
45 changes: 45 additions & 0 deletions src/test/java/com/zipcodewilmington/person/TestPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}