Skip to content

Main #68

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

Main #68

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
1 change: 1 addition & 0 deletions PhoneBook.Maven
Submodule PhoneBook.Maven added at 4c1d35
71 changes: 67 additions & 4 deletions src/main/java/com/zipcodewilmington/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
public class Person {
private String name;
private int age;
private String hairColor;
private String birthMonth;
private String talent;
private char gender;
public String nationality;



public Person() {
}
Expand All @@ -19,17 +26,73 @@ public Person(String name) {
public Person(String name, int age) {
}


public String Person (String talent){

return " " ;
}

public char Person (char gender){

return gender;
}


public String getNationality() {
return nationality;
}

public void setNationality(String nationality) {
this.nationality = nationality;
}

public void setName(String name) {
this.name = name;
}

public void setAge(int age) {
this.age = age;
}

public String getName(String name) {

return name;
}

public Integer getAge(Integer age) {

return age;
}

public String getHairColor(String hairColor) {
return hairColor;
}

public void setHairColor(String hairColor) {
this.hairColor = hairColor;
}

public String getBirthMonth() {
return birthMonth;
}

public void setBirthMonth(String birthMonth) {
this.birthMonth = birthMonth;
}

public String getTalent() {
return talent;
}

public void setTalent(String talent) {
this.talent = talent;
}

public String getName() {
return null;
public char getGender() {
return gender;
}

public Integer getAge() {
return null;
public void setGender(char gender) {
this.gender = gender;
}
}
98 changes: 86 additions & 12 deletions src/test/java/com/zipcodewilmington/person/TestPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,48 @@ public void testDefaultConstructor() {
// Given
String expectedName = "";
Integer expectedAge = Integer.MAX_VALUE;
String expectedHairColor = "pink";
String expectedBirthMonth = "March";

// When
Person person = new Person();

// Then
String actualName = person.getName();
Integer actualAge = person.getAge();
String actualName = person.getName("");
Integer actualAge = person.getAge(Integer.MAX_VALUE);
String actualHairColor = "pink";
String actualBirthMonth = "March";


Assert.assertEquals(expectedName, actualName);
Assert.assertEquals(expectedAge, actualAge);
Assert.assertEquals(expectedHairColor, actualHairColor);
Assert.assertEquals(expectedBirthMonth, actualBirthMonth);
}

@Test
public void testConstructorWithName() {
// Given
Person person = new Person();
String expected = "Leon";

// When
Person person = new Person(expected);
String actual = person.getName("Leon");

// Then
String actual = person.getName();
Assert.assertEquals(expected, actual);
}

@Test
public void testConstructorWithAge() {
// Given
Person person = new Person();
Integer expected = 5;

// When
Person person = new Person(expected);
Integer actual = person.getAge(5);

// Then
Integer actual = person.getAge();
Assert.assertEquals(expected, actual);
}

Expand All @@ -61,8 +68,8 @@ public void testConstructorWithNameAndAge() {
Person person = new Person(expectedName, expectedAge);

// Then
Integer actualAge = person.getAge();
String actualName = person.getName();
Integer actualAge = person.getAge(5);
String actualName = person.getName("Leon");

Assert.assertEquals(expectedAge, actualAge);
Assert.assertEquals(expectedName, actualName);
Expand All @@ -76,7 +83,7 @@ public void testSetName() {

// When
person.setName(expected);
String actual = person.getName();
String actual = person.getName("Leon");

// Then
Assert.assertEquals(expected, actual);
Expand All @@ -86,13 +93,80 @@ public void testSetName() {
public void testSetAge() {
// Given
Person person = new Person();
Integer expected = 5;
Integer expectedAge = 5;

// When
person.setAge(expectedAge);
Integer actual = person.getAge(5);

// Then
Assert.assertEquals(expectedAge, actual);
}
@Test
public void testHairColor() {
// Given
Person person = new Person();
String expected = "pink";

// When
String actual = person.getHairColor("pink");

// Then
Assert.assertEquals(expected, actual);
}
@Test
public void testBirthMonth() {
// Given
Person person = new Person();
String expected = "March";

// When
person.setBirthMonth(expected);
String actual = person.getBirthMonth();

// Then
Assert.assertEquals(expected, actual);
}
@Test
public void testTalent(){
// Given
Person person = new Person();
String expected = "Can Dance";

// When
person.setTalent("Can Dance");
String actual = person.getTalent();

// Then
Assert.assertEquals(expected, actual);
}
@Test
public void testGender(){
// Given
Person person = new Person();
char expected = 'F';

// When
person.setAge(expected);
person.setGender('F');
char actual = person.getGender();

// Then
Integer actual = person.getAge();
Assert.assertEquals(expected, actual);
}
@Test
public void testNationality(){
// Given
Person person = new Person();
String expected = "American";

// When
person.setNationality("American");
String actual = person.getNationality();

// Then
Assert.assertEquals(expected, actual);
}



}