From 4d68c7c2247000f9772d5c504e2784d80b293ab1 Mon Sep 17 00:00:00 2001 From: Zachary Kitto Date: Sat, 3 Jul 2021 12:12:36 -0400 Subject: [PATCH] All tests passed + added 5 new fields & tests --- .../com/zipcodewilmington/person/Person.java | 60 +++++++++++++++- .../zipcodewilmington/person/TestPerson.java | 70 +++++++++++++++++++ 2 files changed, 128 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/person/Person.java b/src/main/java/com/zipcodewilmington/person/Person.java index c12425f..652347f 100644 --- a/src/main/java/com/zipcodewilmington/person/Person.java +++ b/src/main/java/com/zipcodewilmington/person/Person.java @@ -6,30 +6,86 @@ public class Person { private String name; private int age; + private int birthMonth; + private int birthYear; + private char middleInitial; + private String favoriteColor; + private boolean hasAPet; + + + public int getBirthMonth() { + return birthMonth; + } + + public void setBirthMonth(int birthMonth) { + this.birthMonth = birthMonth; + } + + public int getBirthYear() { + return birthYear; + } + + public void setBirthYear(int birthYear) { + this.birthYear = birthYear; + } + + public char getMiddleInitial() { + return middleInitial; + } + + public void setMiddleInitial(char middleInitial) { + this.middleInitial = middleInitial; + } + + public String getFavoriteColor() { + return favoriteColor; + } + + public void setFavoriteColor(String favoriteColor) { + this.favoriteColor = favoriteColor; + } + + public boolean getHasAPet() { + return hasAPet; + } + + public void setHasAPet(boolean hasAPet) { + this.hasAPet = hasAPet; + } 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 void setName(String name) { + this.name = name; } public void setAge(int age) { + this.age = age; } public String getName() { - return null; + return name; } public Integer getAge() { - return null; + return age; } + + } diff --git a/src/test/java/com/zipcodewilmington/person/TestPerson.java b/src/test/java/com/zipcodewilmington/person/TestPerson.java index 59af3b2..23f93e7 100644 --- a/src/test/java/com/zipcodewilmington/person/TestPerson.java +++ b/src/test/java/com/zipcodewilmington/person/TestPerson.java @@ -95,4 +95,74 @@ public void testSetAge() { Integer actual = person.getAge(); Assert.assertEquals(expected, actual); } + + @Test + public void testSetBirthMonth() { + // Given + Person person = new Person(); + Integer expected = 7; + + // When + person.setBirthMonth(expected); + + // Then + Integer actual = person.getBirthMonth(); + Assert.assertEquals(expected, actual); + } + + @Test + public void testSetBirthYear() { + // Given + Person person = new Person(); + Integer expected = 1998; + + // When + person.setBirthYear(expected); + + // Then + Integer actual = person.getBirthYear(); + Assert.assertEquals(expected, actual); + } + + @Test + public void testSetMiddleInitial() { + // Given + Person person = new Person(); + char expected = 'M'; + + // When + person.setMiddleInitial(expected); + + // Then + char actual = person.getMiddleInitial(); + Assert.assertEquals(expected, actual); + } + + @Test + public void testSetFavoriteColor() { + // Given + Person person = new Person(); + String expected = "orange"; + + // When + person.setFavoriteColor(expected); + + // Then + String actual = person.getFavoriteColor(); + Assert.assertEquals(expected, actual); + } + + @Test + public void testSetHasAPet() { + // Given + Person person = new Person(); + boolean expected = false; + + // When + person.setHasAPet(expected); + + // Then + boolean actual = person.getHasAPet(); + Assert.assertEquals(expected, actual); + } }