Skip to content

Commit 2cfdd30

Browse files
LeonLeon
Leon
authored and
Leon
committed
first commit
0 parents  commit 2cfdd30

File tree

5 files changed

+256
-0
lines changed

5 files changed

+256
-0
lines changed

.gitignore

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
Created by .ignore support plugin (hsz.mobi)
2+
### Java template
3+
# Compiled class file
4+
*.class
5+
6+
# Log file
7+
*.log
8+
9+
# BlueJ files
10+
*.ctxt
11+
12+
# Mobile Tools for Java (J2ME)
13+
.mtj.tmp/
14+
15+
# Package Files #
16+
*.jar
17+
*.war
18+
*.ear
19+
*.zip
20+
*.tar.gz
21+
*.rar
22+
23+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
24+
hs_err_pid*
25+
### Eclipse template
26+
27+
.metadata
28+
bin/
29+
tmp/
30+
*.tmp
31+
*.bak
32+
*.swp
33+
*~.nib
34+
local.properties
35+
.settings/
36+
.loadpath
37+
.recommenders
38+
39+
# Eclipse Core
40+
.project
41+
42+
# External tool builders
43+
.externalToolBuilders/
44+
45+
# Locally stored "Eclipse launch configurations"
46+
*.launch
47+
48+
# PyDev specific (Python IDE for Eclipse)
49+
*.pydevproject
50+
51+
# CDT-specific (C/C++ Development Tooling)
52+
.cproject
53+
54+
# JDT-specific (Eclipse Java Development Tools)
55+
.classpath
56+
57+
# Java annotation processor (APT)
58+
.factorypath
59+
60+
# PDT-specific (PHP Development Tools)
61+
.buildpath
62+
63+
# sbteclipse plugin
64+
.target
65+
66+
# Tern plugin
67+
.tern-project
68+
69+
# TeXlipse plugin
70+
.texlipse
71+
72+
# STS (Spring Tool Suite)
73+
.springBeans
74+
75+
# Code Recommenders
76+
.recommenders/
77+
78+
# Scala IDE specific (Scala & Java development for Eclipse)
79+
.cache-main
80+
.scala_dependencies
81+
.worksheet
82+
### macOS template
83+
*.DS_Store
84+
.AppleDouble
85+
.LSOverride
86+
87+
# Icon must end with two \r
88+
Icon
89+
90+
91+
# Thumbnails
92+
._*
93+
94+
# Files that might appear in the root of a volume
95+
.DocumentRevisions-V100
96+
.fseventsd
97+
.Spotlight-V100
98+
.TemporaryItems
99+
.Trashes
100+
.VolumeIcon.icns
101+
.com.apple.timemachine.donotpresent
102+
103+
# Directories potentially created on remote AFP share
104+
.AppleDB
105+
.AppleDesktop
106+
Network Trash Folder
107+
Temporary Items
108+
.apdisk
109+
110+
#Intellij files
111+
.idea
112+
*.iml
113+
114+
#maven build target
115+
target/

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Creating and Testing Person class
2+
* **Purpose** - to demonstrate the use of [Java Classes](https://docs.oracle.com/javase/tutorial/java/concepts/class.html).
3+
* **Objective** - to implement a Java Class which encapsulates data about a `Person` object
4+
5+
6+
* **Ensure Each Test Passes Successfully**
7+
* Ensure the class `TestPerson` has 100% success rate before continuing.
8+
9+
* **Finish Features**
10+
* Add 5 different fields to the `Person` class.
11+
* Ensure each of the methods for manipulating and accessing these fields have appropriate testing in the `TestPerson`.

pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.zipcodewilmington</groupId>
8+
<artifactId>person</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<dependencies>
11+
<dependency>
12+
<groupId>junit</groupId>
13+
<artifactId>junit</artifactId>
14+
<version>RELEASE</version>
15+
</dependency>
16+
</dependencies>
17+
18+
19+
</project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.zipcodewilmington.person;
2+
3+
/**
4+
* Created by leon on 2/12/18.
5+
*/
6+
public class Person {
7+
private String name;
8+
private int age;
9+
10+
public Person() {
11+
}
12+
13+
public Person(int age) {
14+
}
15+
16+
public Person(String name) {
17+
}
18+
19+
public Person(String name, int age) {
20+
}
21+
22+
public void setName(String name) {
23+
}
24+
25+
public void setAge(int age) {
26+
}
27+
28+
public String getName() {
29+
return null;
30+
}
31+
32+
public Integer getAge() {
33+
return null;
34+
}
35+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package com.zipcodewilmington.person;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
6+
/**
7+
* Created by leon on 2/12/18.
8+
*/
9+
public class TestPerson {
10+
@Test
11+
public void testDefaultConstructor() {
12+
String expectedName = "";
13+
Integer expectedAge = Integer.MAX_VALUE;
14+
15+
Person person = new Person();
16+
17+
String actualName = person.getName();
18+
Integer actualAge = person.getAge();
19+
20+
Assert.assertEquals(expectedName, actualName);
21+
Assert.assertEquals(expectedAge, actualAge);
22+
}
23+
24+
@Test
25+
public void testConstructorWithName(){
26+
String expected = "Leon";
27+
Person person = new Person(expected);
28+
String actual = person.getName();
29+
Assert.assertEquals(expected, actual);
30+
}
31+
32+
@Test
33+
public void testConstructorWithAge(){
34+
Integer expected = 5;
35+
Person person = new Person(expected);
36+
person.setAge(expected);
37+
String actual = person.getName();
38+
Assert.assertEquals(expected, actual);
39+
}
40+
41+
42+
43+
44+
45+
@Test
46+
public void testConstructorWithNameAndAge(){
47+
Integer expectedAge = 5;
48+
String expectedName = "Leon";
49+
50+
Person person = new Person(expectedName, expectedAge);
51+
52+
Integer actualAge = person.getAge();
53+
String actualName = person.getName();
54+
55+
Assert.assertEquals(expectedAge, actualAge);
56+
Assert.assertEquals(expectedName, actualName);
57+
}
58+
59+
@Test
60+
public void testSetName() {
61+
Person person = new Person();
62+
String expected = "Leon";
63+
person.setName(expected);
64+
String actual = person.getName();
65+
Assert.assertEquals(expected, actual);
66+
}
67+
68+
@Test
69+
public void testSetAge() {
70+
Person person = new Person();
71+
Integer expected = 5;
72+
person.setAge(expected);
73+
Integer actual = person.getAge();
74+
Assert.assertEquals(expected, actual);
75+
}
76+
}

0 commit comments

Comments
 (0)