diff --git a/.idea/$PRODUCT_WORKSPACE_FILE$ b/.idea/$PRODUCT_WORKSPACE_FILE$
new file mode 100644
index 00000000..9fba8c61
--- /dev/null
+++ b/.idea/$PRODUCT_WORKSPACE_FILE$
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+ 1.8.0_201
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000..5c98b428
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,2 @@
+# Default ignored files
+/workspace.xml
\ No newline at end of file
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 00000000..a0f2c3a1
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+interfaces-1
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 00000000..8f6ee9db
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 00000000..b26911bd
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__junit_junit_4_12.xml b/.idea/libraries/Maven__junit_junit_4_12.xml
new file mode 100644
index 00000000..d4110417
--- /dev/null
+++ b/.idea/libraries/Maven__junit_junit_4_12.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
new file mode 100644
index 00000000..f58bbc11
--- /dev/null
+++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..3e62a0b4
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..711b3a53
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 00000000..e96534fb
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..94a25f7f
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 96882643..8f79acec 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# Leon's Lengthy Learner Lab
-* **Objective** - to implement a `ZipCodeWilmington` class which _mediates_ a _composite_ `Students` and `Instructors` _singleton_ reference.
+* **Objective** - to implement a `ZipCodeWilmington` class which _mediates_ a _composite_ `io.zipcoder.interfaces.Students` and `Instructors` _singleton_ reference.
* **Purpose** - to demonstrate the use of
* [interfaces](https://stackoverflow.com/questions/1321122/what-is-an-interface-in-java)
* [abstract classes](https://stackoverflow.com/questions/1320745/abstract-class-in-java)
@@ -111,11 +111,11 @@
-
-### Part 7.1 - Create `Students` singleton
+### Part 7.1 - Create `io.zipcoder.interfaces.Students` singleton
* **Note:** The creation of this class will demonstrate an implementation of [singleton design pattern](https://www.journaldev.com/1377/java-singleton-design-pattern-best-practices-examples#eager-initialization).
-* Create a `Students` class.
+* Create a `io.zipcoder.interfaces.Students` class.
* The class should be an _unextendable_ subclass of the `People` class.
- * The class should _statically instantiate_ a `final` field named `INSTANCE` of type `Students`.
+ * The class should _statically instantiate_ a `final` field named `INSTANCE` of type `io.zipcoder.interfaces.Students`.
* The class should define a _private nullary constructor_ which populates the `INSTANCE` field with respective `Student` representations of your colleagues.
* Each student should have a _relatively_ unique `id` field.
* The class should define a `getInstance` method which returns the `INSTANCE` field.
@@ -123,9 +123,9 @@
-
-### Part 7.0 - Test `Students` singleton
+### Part 7.0 - Test `io.zipcoder.interfaces.Students` singleton
* Create a `TestStudents` class.
- * Create a `test` method which ensures that each of the students in your current cohort are in your `Students` singleton.
+ * Create a `test` method which ensures that each of the students in your current cohort are in your `io.zipcoder.interfaces.Students` singleton.
@@ -139,7 +139,7 @@
-
### Part 9.1 - Create `ZipCodeWilmington` Class
* Create a `ZipCodeWilmington` singleton.
- * The class should declare a field that references the instance of `Students` called `students`.
+ * The class should declare a field that references the instance of `io.zipcoder.interfaces.Students` called `students`.
* The class should declare a field that references the instance of `Instructors` called `instructors`.
* The class should define a method `hostLecture` which makes use of a `Teacher teacher, double numberOfHours` parameter to host a `lecture` to the composite `personList` field in the `students` reference.
* The class should define a method `hostLecture` which makes use of a `long id, double numberOfHours` parameter to identify a respective `Instructor` to host a `lecture` to the composite `personList` field in the `cohort` reference.
@@ -176,7 +176,7 @@
-
### Part 10.2 - Modify `People` subclasses
-* Modify the `Students` class signature to ensure that it is a subclass of `People` of parameterized type `Student`.
+* Modify the `io.zipcoder.interfaces.Students` class signature to ensure that it is a subclass of `People` of parameterized type `Student`.
* Modify the `Instructors` class signature to ensure that it is a subclass of `People` of parameterized type `Instructor`.
* Provide concrete implementations of the `getArray` method in each of these classes.
diff --git a/interfaces-1.iml b/interfaces-1.iml
new file mode 100644
index 00000000..4e3316bc
--- /dev/null
+++ b/interfaces-1.iml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/io/zipcoder/interfaces/Educator.java b/src/main/java/io/zipcoder/interfaces/Educator.java
new file mode 100644
index 00000000..e09867c6
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Educator.java
@@ -0,0 +1,25 @@
+package io.zipcoder.interfaces;
+
+public enum Educator implements Teacher {
+
+ ONE(new Instructor(2323L, "BIP")), BOOP(new Instructor(3232L, "BOOP"));
+
+ Instructor instructor;
+ Double timeWorked = 0D;
+
+ Educator(Instructor instructor) {
+ this.instructor = instructor;
+ }
+
+ @Override
+ public void teach(Learner learner, Double numberOfHours) {
+ this.instructor.teach(learner,numberOfHours);
+ this.timeWorked += numberOfHours;
+ }
+
+ @Override
+ public void lecture(Learner[] learners, Double numberOfHours) {
+ this.instructor.lecture(learners, numberOfHours);
+ this.timeWorked += numberOfHours;
+ }
+}
diff --git a/src/main/java/io/zipcoder/interfaces/Instructor.java b/src/main/java/io/zipcoder/interfaces/Instructor.java
new file mode 100644
index 00000000..1131ac1a
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Instructor.java
@@ -0,0 +1,18 @@
+package io.zipcoder.interfaces;
+
+public class Instructor extends Person implements Teacher {
+ public Instructor(Long id, String name) {
+ super(id, name);
+ }
+
+ public void teach(Learner learner, Double numberOfHours) {
+ learner.learn(numberOfHours);
+ }
+
+ public void lecture(Learner[] learners, Double numberOfHours) {
+ Double numberOfHoursPerLearner = numberOfHours / learners.length;
+ for(Learner l : learners){
+ l.learn(numberOfHoursPerLearner);
+ }
+ }
+}
diff --git a/src/main/java/io/zipcoder/interfaces/Instructors.java b/src/main/java/io/zipcoder/interfaces/Instructors.java
new file mode 100644
index 00000000..d35d0657
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Instructors.java
@@ -0,0 +1,23 @@
+package io.zipcoder.interfaces;
+
+public class Instructors extends People {
+
+ public static final Instructors INSTANCE = new Instructors();
+
+ private Instructors(){
+ Instructor instructor1 = new Instructor(2323L, "Boop");
+ Instructor instructor2 = new Instructor(3232L, "Bip");
+ personList.add(instructor1);
+ personList.add(instructor2);
+
+ }
+
+ public static Instructors getInstance(){
+ return INSTANCE;
+ }
+
+ @Override
+ public Instructor[] toArray() {
+ return personList.toArray(new Instructor[personList.size()]);
+ }
+}
diff --git a/src/main/java/io/zipcoder/interfaces/Learner.java b/src/main/java/io/zipcoder/interfaces/Learner.java
new file mode 100644
index 00000000..8fbf0de9
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Learner.java
@@ -0,0 +1,7 @@
+package io.zipcoder.interfaces;
+
+public interface Learner {
+
+ void learn(Double numberOfHours);
+ Double getTotalStudyTime();
+}
diff --git a/src/main/java/io/zipcoder/interfaces/People.java b/src/main/java/io/zipcoder/interfaces/People.java
new file mode 100644
index 00000000..78a91531
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/People.java
@@ -0,0 +1,64 @@
+package io.zipcoder.interfaces;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Spliterator;
+import java.util.function.Consumer;
+
+public abstract class People implements Iterable{
+ public List personList = new ArrayList<>();
+
+ public void add(E person){
+ this.personList.add(person);
+ }
+
+ public E findByID(Long id){
+ for(E p : personList){
+ if(p.getId().equals(id)){
+ return p;
+ }
+ }
+ return null;
+ }
+
+ public Boolean contains(Person person){
+ for(Person p : personList){
+ if(p.toString().equals(person.toString())){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void remove(E person){
+ this.personList.remove(person);
+ }
+
+ public void remove(Long id){
+ Person p = findByID(id);
+ this.personList.remove(p);
+ }
+
+ public void removeAll(){
+ this.personList.clear();
+ }
+
+ public Integer count(){
+ return personList.size();
+ }
+
+ public abstract E[] toArray();
+
+ public Iterator iterator() {
+ return personList.iterator();
+ }
+
+ public void forEach(Consumer super E> action) {
+
+ }
+
+ public Spliterator spliterator() {
+ return null;
+ }
+}
diff --git a/src/main/java/io/zipcoder/interfaces/Person.java b/src/main/java/io/zipcoder/interfaces/Person.java
index fc6a3ffe..82a99c74 100644
--- a/src/main/java/io/zipcoder/interfaces/Person.java
+++ b/src/main/java/io/zipcoder/interfaces/Person.java
@@ -2,4 +2,24 @@
public class Person {
+ private final Long id;
+ private String name;
+
+ public Person(Long id, String name){
+ this.id = id;
+ this.name = name;
+ }
+
+ public String getName(){
+ return name;
+ }
+
+ public Long getId(){
+ return id;
+ }
+
+ public void setName(String name){
+ this.name = name;
+ }
+
}
diff --git a/src/main/java/io/zipcoder/interfaces/Student.java b/src/main/java/io/zipcoder/interfaces/Student.java
new file mode 100644
index 00000000..90e0dd7b
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Student.java
@@ -0,0 +1,20 @@
+package io.zipcoder.interfaces;
+
+public class Student extends Person implements Learner {
+
+ private double totalStudyTime;
+
+ public Student(Long id, String name) {
+ super(id, name);
+ }
+
+ public void learn(Double numberOfHours) {
+ totalStudyTime += numberOfHours;
+ }
+
+ public Double getTotalStudyTime() {
+ return totalStudyTime;
+ }
+
+ public void setTotalStudyTime(Double totalStudyTime) {this.totalStudyTime = totalStudyTime; }
+}
diff --git a/src/main/java/io/zipcoder/interfaces/Students.java b/src/main/java/io/zipcoder/interfaces/Students.java
new file mode 100644
index 00000000..135e0087
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Students.java
@@ -0,0 +1,28 @@
+package io.zipcoder.interfaces;
+
+public class Students extends People {
+
+ public static final Students INSTANCE = new Students();
+
+ private Students() {
+ Student student = new Student(34L, "Gau");
+ Student student2 = new Student(45L, "Sabin");
+ Student student3 = new Student(67L, "Cyan");
+ Student student4 = new Student(81L, "Shadow");
+ personList.add(student);
+ personList.add(student2);
+ personList.add(student3);
+ personList.add(student4);
+ }
+
+
+ public static Students getInstance(){
+ return INSTANCE;
+ }
+
+
+ @Override
+ public Student[] toArray() {
+ return personList.toArray(new Student[personList.size()]) ;
+ }
+}
diff --git a/src/main/java/io/zipcoder/interfaces/Teacher.java b/src/main/java/io/zipcoder/interfaces/Teacher.java
new file mode 100644
index 00000000..19eefb78
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/Teacher.java
@@ -0,0 +1,7 @@
+package io.zipcoder.interfaces;
+
+public interface Teacher {
+
+ void teach(Learner learner, Double numberOfHours);
+ void lecture(Learner[] learner, Double numberOfHours);
+}
diff --git a/src/main/java/io/zipcoder/interfaces/ZipCodeWilmington.java b/src/main/java/io/zipcoder/interfaces/ZipCodeWilmington.java
new file mode 100644
index 00000000..3d23a34a
--- /dev/null
+++ b/src/main/java/io/zipcoder/interfaces/ZipCodeWilmington.java
@@ -0,0 +1,25 @@
+package io.zipcoder.interfaces;
+
+import java.util.HashMap;
+
+public class ZipCodeWilmington {
+ private static final ZipCodeWilmington INSTANCE = new ZipCodeWilmington();
+ private static final Students students = Students.getInstance();
+ private static final Instructors instructors = Instructors.getInstance();
+
+ public void hostLecture(Teacher teacher, Double numberOfHours){
+ teacher.lecture(students.toArray(), numberOfHours);
+ }
+
+ public void hostLecture(Long id, Double numberOfHours){
+ Teacher teacher = instructors.findByID(id);
+ teacher.lecture(students.toArray(),numberOfHours);
+ }
+
+ public HashMap getStudyMap(Student student){
+ HashMap studyMap= new HashMap<>();
+ studyMap.put(student, student.getTotalStudyTime());
+
+ return studyMap;
+ }
+}
diff --git a/src/test/java/io/zipcoder/interfaces/EducatorTest.java b/src/test/java/io/zipcoder/interfaces/EducatorTest.java
new file mode 100644
index 00000000..e4b883bc
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/EducatorTest.java
@@ -0,0 +1,39 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class EducatorTest {
+
+ @Test
+ public void testImplementation(){
+ Educator instructor = Educator.BOOP;
+ Assert.assertTrue(instructor instanceof Teacher);
+ }
+
+ @Test
+ public void teach() {
+ Student student = new Student(null,null);
+ Double numberOfHours = 3D;
+ Educator.BOOP.teach(student, numberOfHours);
+ Double expectedHours = 3D;
+
+ Assert.assertEquals(expectedHours, student.getTotalStudyTime());
+ }
+
+ @Test
+ public void lecture() {
+ Instructor instructor = new Instructor(null, null);
+ Student student = new Student(null, null);
+ Student student2 = new Student(null, null);
+ Student student3 = new Student(null, null);
+ Learner[] students = {student, student2, student3};
+ Double numberOfHours = 9D;
+ Double totalHoursSplit = numberOfHours / students.length;
+ Educator.BOOP.lecture(students, numberOfHours);
+
+ Assert.assertEquals(totalHoursSplit, student.getTotalStudyTime());
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/io/zipcoder/interfaces/InstructorTest.java b/src/test/java/io/zipcoder/interfaces/InstructorTest.java
new file mode 100644
index 00000000..d38e2f9e
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/InstructorTest.java
@@ -0,0 +1,43 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class InstructorTest {
+ @Test
+ public void testImplementation(){
+ Instructor instructor = new Instructor(null,null);
+ Assert.assertTrue(instructor instanceof Teacher);
+ }
+
+ @Test
+ public void testInheritance(){
+ Instructor instructor = new Instructor(null,null);
+ Assert.assertTrue(instructor instanceof Person);
+ }
+ @Test
+ public void testTeach() {
+ Instructor instructor = new Instructor(null,null);
+ Student student = new Student(null,null);
+ Double expected = 10D;
+ instructor.teach(student,expected);
+
+ Assert.assertEquals(expected,student.getTotalStudyTime());
+ }
+
+ @Test
+ public void testLecture() {
+ Instructor instructor = new Instructor(null, null);
+ Student student = new Student(null, null);
+ Student student2 = new Student(null, null);
+ Student student3 = new Student(null, null);
+ Learner[] students = {student, student2, student3};
+ Double numberOfHours = 9D;
+ Double totalHoursSplit = numberOfHours / students.length;
+
+ instructor.lecture(students, numberOfHours);
+ Assert.assertEquals(totalHoursSplit, student.getTotalStudyTime());
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/io/zipcoder/interfaces/InstructorsTest.java b/src/test/java/io/zipcoder/interfaces/InstructorsTest.java
new file mode 100644
index 00000000..fcbc5951
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/InstructorsTest.java
@@ -0,0 +1,33 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class InstructorsTest {
+
+ @Test
+ public void getInstanceTest1() {
+ Instructors instructors = Instructors.INSTANCE;
+
+ Integer expectedSize = 2;
+ Integer actualSize = instructors.personList.size();
+
+ Assert.assertEquals(expectedSize,actualSize);
+ }
+
+ @Test
+ public void getInstanceTest2(){
+ Instructors instructors = Instructors.INSTANCE;
+ Boolean instructor = false;
+
+ for(Person person : instructors.personList){
+ if(person.getId() == 2323L && person.getName().equals("Boop")){
+ instructor = true;
+ break;
+ }
+ }
+ Assert.assertTrue(instructor);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/io/zipcoder/interfaces/PeopleTest.java b/src/test/java/io/zipcoder/interfaces/PeopleTest.java
new file mode 100644
index 00000000..a060cf58
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/PeopleTest.java
@@ -0,0 +1,62 @@
+package io.zipcoder.interfaces;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class PeopleTest {
+
+ @Test
+ public void addTest() {
+ Student student = new Student(34L,"Gau");
+ Student student2 = new Student(45L,"Cyan");
+ Students students = Students.getInstance();
+
+ students.add(student);
+ students.add(student2);
+ Assert.assertTrue(students.contains(student));
+ }
+
+ @Test
+ public void addTest2() {
+ Student student = new Student(34L,"Gau");
+ Student student2 = new Student(45L,"Cyan");
+ Students students = Students.getInstance();
+
+ students.add(student);
+ students.add(student2);
+ Assert.assertEquals(6,students.personList.size());
+ }
+
+ @Test
+ public void findByID() {
+ Long id = 34L;
+ String expected = "Gau";
+ Person person = new Person(id,expected);
+ Students students = Students.getInstance();
+
+ String actual = students.findByID(id).getName();
+
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void remove() {
+ Instructor instructor = new Instructor(null,null);
+ Instructors instructors = Instructors.getInstance();
+ instructors.add(instructor);
+ instructors.remove(instructor);
+
+ Assert.assertFalse(instructors.contains(instructor));
+ }
+
+ @After
+ public void clearInstance(){
+ Students students = Students.getInstance();
+ for(int i = 4; i < students.personList.size(); i++){
+ students.personList.remove(i);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/io/zipcoder/interfaces/StudentTest.java b/src/test/java/io/zipcoder/interfaces/StudentTest.java
new file mode 100644
index 00000000..1389fab2
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/StudentTest.java
@@ -0,0 +1,30 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class StudentTest {
+
+ @Test
+ public void learn() {
+ Student student = new Student(null,null);
+ Double expected = 10D;
+ student.learn(expected);
+
+ Assert.assertEquals(expected,student.getTotalStudyTime());
+ }
+
+ @Test
+ public void testImplementation(){
+ Student student = new Student(null,null);
+ Assert.assertTrue(student instanceof Person);
+ }
+
+ @Test
+ public void testInheritance(){
+ Student student = new Student(null,null);
+ Assert.assertTrue(student instanceof Learner);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/io/zipcoder/interfaces/StudentsTest.java b/src/test/java/io/zipcoder/interfaces/StudentsTest.java
new file mode 100644
index 00000000..6c07c32d
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/StudentsTest.java
@@ -0,0 +1,33 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class StudentsTest {
+
+ @Test
+ public void getInstanceTest1() {
+ Students students = Students.INSTANCE;
+
+ Integer expectedSize = 4;
+ Integer actualSize = students.personList.size();
+
+ Assert.assertEquals(expectedSize,actualSize);
+ }
+
+ @Test
+ public void getInstanceTest2(){
+ Students students = Students.INSTANCE;
+ boolean student = false;
+
+ for(Person person : students.personList){
+ if(person.getId() == 34L && person.getName().equals("Gau")){
+ student = true;
+ break;
+ }
+ }
+ Assert.assertTrue(student);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/io/zipcoder/interfaces/TestPerson.java b/src/test/java/io/zipcoder/interfaces/TestPerson.java
index d64cd2f0..e0cec1b4 100644
--- a/src/test/java/io/zipcoder/interfaces/TestPerson.java
+++ b/src/test/java/io/zipcoder/interfaces/TestPerson.java
@@ -1,5 +1,30 @@
package io.zipcoder.interfaces;
+import org.junit.Assert;
+import org.junit.Test;
+
public class TestPerson {
+ @Test
+ public void testConstructor(){
+ Long expectedId = 34L;
+ String expectedName = "Gau";
+ Person person = new Person( expectedId , expectedName);
+ Long actualId = person.getId();
+ String actualName = person.getName();
+
+ Assert.assertEquals(expectedId,actualId);
+ Assert.assertEquals(expectedName,actualName);
+ }
+
+ @Test
+ public void testSetName(){
+ Person person = new Person( null , null);
+ String expected = "Gau";
+ person.setName(expected);
+ String actual = person.getName();
+
+ Assert.assertEquals(expected,actual);
+ }
+
}
diff --git a/src/test/java/io/zipcoder/interfaces/ZipCodeWilmingtonTest.java b/src/test/java/io/zipcoder/interfaces/ZipCodeWilmingtonTest.java
new file mode 100644
index 00000000..4e4ad0df
--- /dev/null
+++ b/src/test/java/io/zipcoder/interfaces/ZipCodeWilmingtonTest.java
@@ -0,0 +1,82 @@
+package io.zipcoder.interfaces;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.HashMap;
+
+import static org.junit.Assert.*;
+
+public class ZipCodeWilmingtonTest {
+
+ @Before
+ public void singletonReset(){
+ Students students = Students.getInstance();
+ for(Student s: students.personList){
+ s.setTotalStudyTime(0D);
+ }
+ }
+
+ @Test
+ public void hostLectureByTeacherTest() {
+ Students students = Students.getInstance();
+ Instructors instructors = Instructors.getInstance();
+ Long expectedTeacherId = 2323L;
+ Teacher teacher = instructors.findByID(expectedTeacherId);
+ Long expectedStudentId = 34L;
+ Student student = students.findByID(expectedStudentId);
+ Double numberOfHours = 12D;
+ ZipCodeWilmington zipCodeWilmington = new ZipCodeWilmington();
+ zipCodeWilmington.hostLecture(teacher,numberOfHours);
+ Double expectedHours = 3D;
+
+ Assert.assertEquals(expectedHours, student.getTotalStudyTime());
+ }
+
+ @Test
+ public void hostLectureByIdTest() {
+ Students students = Students.getInstance();
+ Long expectedTeacherId = 2323L;
+ Long expectedStudentId = 34L;
+ Student student = students.findByID(expectedStudentId);
+ Double numberOfHours = 12D;
+ ZipCodeWilmington zipCodeWilmington = new ZipCodeWilmington();
+ zipCodeWilmington.hostLecture(expectedTeacherId,numberOfHours);
+ Double expectedHours = 3D;
+
+ Assert.assertEquals(expectedHours, student.getTotalStudyTime());
+ }
+
+ @Test
+ public void hostByLectureEducatorTest() {
+ Students students = Students.getInstance();
+ Educator educator = Educator.BOOP;
+ Long expectedStudentId = 34L;
+ Student student = students.findByID(expectedStudentId);
+ Double numberOfHours = 12D;
+ ZipCodeWilmington zipCodeWilmington = new ZipCodeWilmington();
+ zipCodeWilmington.hostLecture(educator,numberOfHours);
+ Double expectedHours = 3D;
+
+ Assert.assertEquals(expectedHours, student.getTotalStudyTime());
+ }
+
+ @Test
+ public void getStudyMapTest(){
+ Students students = Students.getInstance();
+ Long expectedTeacherId = 2323L;
+ Long expectedStudentId = 34L;
+ Student student = students.findByID(expectedStudentId);
+ Double expectedHours = 3D;
+ Double numberOfHours = 12D;
+ ZipCodeWilmington zipCodeWilmington = new ZipCodeWilmington();
+ zipCodeWilmington.hostLecture(expectedTeacherId,numberOfHours);
+ HashMap expectedHashMap = new HashMap<>();
+
+ expectedHashMap.put(student,expectedHours);
+ HashMap actualHashMap = zipCodeWilmington.getStudyMap(student);
+
+ Assert.assertEquals(expectedHashMap.get(student), actualHashMap.get(student));
+ }
+}
\ No newline at end of file